Skip to content

Commit

Permalink
chore: update rubocop (#341)
Browse files Browse the repository at this point in the history
* chore: bump version to 5.0.0 rc5

* chore: update rubocop

* update

* ci: use Ruby 3

* bump macOS and xcode version
  • Loading branch information
KazuCocoa authored Oct 18, 2021
1 parent e13b0ef commit ad519ee
Show file tree
Hide file tree
Showing 14 changed files with 123 additions and 39 deletions.
90 changes: 89 additions & 1 deletion .rubocop.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
AllCops:
TargetRubyVersion: 2.4
TargetRubyVersion: 2.6
Layout/LineLength:
Max: 128
Layout/RescueEnsureAlignment:
Expand Down Expand Up @@ -56,3 +56,91 @@ Style/ExplicitBlockArgument:
Enabled: false
Style/KeywordParametersOrder:
Enabled: false
Gemspec/DateAssignment:
Enabled: true
Layout/LineEndStringConcatenationIndentation:
Enabled: true
Layout/SpaceBeforeBrackets:
Enabled: true
Lint/AmbiguousAssignment:
Enabled: true
Lint/AmbiguousOperatorPrecedence:
Enabled: false
Lint/AmbiguousRange:
Enabled: true
Lint/DeprecatedConstants:
Enabled: true
Lint/DuplicateBranch:
Enabled: true
Lint/DuplicateRegexpCharacterClassElement:
Enabled: true
Lint/EmptyBlock:
Enabled: true
Lint/EmptyClass:
Enabled: true
Lint/EmptyInPattern:
Enabled: true
Lint/IncompatibleIoSelectWithFiberScheduler:
Enabled: true
Lint/LambdaWithoutLiteralBlock:
Enabled: true
Lint/NoReturnInBeginEndBlocks:
Enabled: true
Lint/NumberedParameterAssignment:
Enabled: true
Lint/OrAssignmentToConstant:
Enabled: true
Lint/RedundantDirGlobSort:
Enabled: true
Lint/RequireRelativeSelfPath:
Enabled: true
Lint/SymbolConversion:
Enabled: true
Lint/ToEnumArguments:
Enabled: true
Lint/TripleQuotes:
Enabled: true
Lint/UnexpectedBlockArity:
Enabled: true
Lint/UnmodifiedReduceAccumulator:
Enabled: true
Security/IoMethods:
Enabled: true
Style/ArgumentsForwarding:
Enabled: true
Style/CollectionCompact:
Enabled: true
Style/DocumentDynamicEvalDefinition:
Enabled: true
Style/EndlessMethod:
Enabled: true
Style/HashConversion:
Enabled: true
Style/HashExcept:
Enabled: true
Style/IfWithBooleanLiteralBranches:
Enabled: true
Style/InPatternThen:
Enabled: true
Style/MultilineInPatternThen:
Enabled: true
Style/NegatedIfElseCondition:
Enabled: true
Style/NilLambda:
Enabled: true
Style/NumberedParameters:
Enabled: true
Style/NumberedParametersLimit:
Enabled: true
Style/QuotedSymbols:
Enabled: true
Style/RedundantArgument:
Enabled: true
Style/RedundantSelfAssignmentBranch:
Enabled: true
Style/SelectByRegexp:
Enabled: true
Style/StringChars:
Enabled: true
Style/SwapValues:
Enabled: true
2 changes: 1 addition & 1 deletion appium_lib_core.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ Gem::Specification.new do |spec|
spec.add_development_dependency 'minitest', '~> 5.0'
spec.add_development_dependency 'minitest-reporters', '~> 1.1'
spec.add_development_dependency 'webmock', '~> 3.14.0'
spec.add_development_dependency 'rubocop', '1.12.1'
spec.add_development_dependency 'rubocop', '1.22.1'
spec.add_development_dependency 'appium_thor', '~> 1.0'
spec.add_development_dependency 'pry'
spec.add_development_dependency 'pry-byebug'
Expand Down
2 changes: 1 addition & 1 deletion ci-jobs/functional/run_appium.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ steps:
displayName: Installed node dependencies
- task: UseRubyVersion@0
inputs:
versionSpec: '2.7'
versionSpec: '3.0'
- script: |
mkdir -p test/report
nohup appium --relaxed-security --log-timestamp --log-no-colors > test/report/appium.out 2>&1 &
Expand Down
8 changes: 4 additions & 4 deletions ci-jobs/functional_test.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
# jobs for functional test
parameters:
vmImage: 'macOS-10.15'
vmImageForIOS: 'macOS-10.15' # Not sure the reason, but macOS 10.14 instance raises no info.plist error
xcodeForIOS: 12.2
xcodeForTVOS: 12.2
vmImage: 'macOS-11'
vmImageForIOS: 'macOS-11'
xcodeForIOS: 12.5.1
xcodeForTVOS: 12.5.1
androidSDK: 29 # API Level 30 emulators are more unstable than 29
appiumVersion: 'beta'
ignoreVersionSkip: true
Expand Down
12 changes: 5 additions & 7 deletions lib/appium_lib_core/common/base/bridge.rb
Original file line number Diff line number Diff line change
Expand Up @@ -187,8 +187,8 @@ def session_capabilities

# Port from MJSONWP
def send_keys_to_active_element(key)
text = ::Selenium::WebDriver::Keys.encode(key).join('')
execute :send_keys_to_active_element, {}, { value: text.split(//) }
text = ::Selenium::WebDriver::Keys.encode(key).join
execute :send_keys_to_active_element, {}, { value: text.chars }
end

# For Appium
Expand Down Expand Up @@ -319,11 +319,9 @@ def log(type)
data = execute :get_log, {}, { type: type.to_s }

Array(data).map do |l|
begin
::Selenium::WebDriver::LogEntry.new l.fetch('level', 'UNKNOWN'), l.fetch('timestamp'), l.fetch('message')
rescue KeyError
next
end
::Selenium::WebDriver::LogEntry.new l.fetch('level', 'UNKNOWN'), l.fetch('timestamp'), l.fetch('message')
rescue KeyError
next
end
end

Expand Down
2 changes: 1 addition & 1 deletion lib/appium_lib_core/common/base/driver.rb
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ def create_bridge(**opts)
def update_sending_request_to(protocol:, host:, port:, path:)
unless @bridge.http&.class&.method_defined? :update_sending_request_to
::Appium::Logger.warn "#{@bridge.http&.class} has no 'update_sending_request_to'. " \
'It keeps current connection target.'
'It keeps current connection target.'
return
end

Expand Down
4 changes: 2 additions & 2 deletions lib/appium_lib_core/common/base/screenshot.rb
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,8 @@ def screenshot_as(format)
def save_element_screenshot(element, png_path)
extension = File.extname(png_path).downcase
if extension != '.png'
::Appium::Logger.warn 'name used for saved screenshot does not match file type. '\
'It should end with .png extension'
::Appium::Logger.warn 'name used for saved screenshot does not match file type. ' \
'It should end with .png extension'
end
File.open(png_path, 'wb') { |f| f << element_screenshot_as(element, :png) }
end
Expand Down
4 changes: 2 additions & 2 deletions lib/appium_lib_core/common/device/value.rb
Original file line number Diff line number Diff line change
Expand Up @@ -39,11 +39,11 @@ def generate_value_and_text(*value)
end

# Keep .split(//) for backward compatibility for now
text = keys.join('')
text = keys.join

# FIXME: further work for W3C. Over appium 1.15.0 or later
# { value: text.split(//), text: text }
{ value: text.split(//) }
{ value: text.chars }
end
end # module Value
end # module Device
Expand Down
4 changes: 2 additions & 2 deletions lib/appium_lib_core/version.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

module Appium
module Core
VERSION = '5.0.0.rc4' unless defined? ::Appium::Core::VERSION
DATE = '2021-10-14' unless defined? ::Appium::Core::DATE
VERSION = '5.0.0.rc5' unless defined? ::Appium::Core::VERSION
DATE = '2021-10-15' unless defined? ::Appium::Core::DATE
end
end
4 changes: 2 additions & 2 deletions test/functional/android/android/device_data_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ def teardown

def test_push_and_pull_file
file = 'aVZCT1J3MEtHZ29BQUF BTlNVaEVVZ0FBQXU0QUFB VTJDQUlBQUFCRnRhUl' \
'JBQUFBQVhOU1IwSUFyczRjNlFBQQ0KQUJ4cFJFOVVBQUFBQWdBQUFBQUFBQUti'
'JBQUFBQVhOU1IwSUFyczRjNlFBQQ0KQUJ4cFJFOVVBQUFBQWdBQUFBQUFBQUti'
path = '/data/local/tmp/remote.txt'
@@core.wait do
@driver.push_file path, file
Expand All @@ -42,7 +42,7 @@ def test_push_and_pull_file

def test_pull_folder
file = 'aVZCT1J3MEtHZ29BQUF BTlNVaEVVZ0FBQXU0QUFB VTJDQUlBQUFCRnRhUl' \
'JBQUFBQVhOU1IwSUFyczRjNlFBQQ0KQUJ4cFJFOVVBQUFBQWdBQUFBQUFBQUti'
'JBQUFBQVhOU1IwSUFyczRjNlFBQQ0KQUJ4cFJFOVVBQUFBQWdBQUFBQUFBQUti'
path = '/data/local/tmp/remote.txt'
@driver.push_file path, file

Expand Down
14 changes: 6 additions & 8 deletions test/functional/android/android/device_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -362,14 +362,12 @@ def scroll_to(text)
[rid]
end
args.each_with_index do |arg, index|
begin
elem = @driver.find_element :uiautomator,
'new UiScrollable(new UiSelector().scrollable(true).instance(0))' \
".scrollIntoView(#{arg}.instance(0));"
return elem
rescue StandardError => e
raise e if index == args.size - 1
end
elem = @driver.find_element :uiautomator,
'new UiScrollable(new UiSelector().scrollable(true).instance(0))' \
".scrollIntoView(#{arg}.instance(0));"
return elem
rescue StandardError => e
raise e if index == args.size - 1
end
end
end
Expand Down
6 changes: 3 additions & 3 deletions test/functional/ios/ios/device_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ def test_app_management
{
bundleId: 'com.example.apple-samplecode.UICatalog',
arguments: %w(arg1 arg2),
environment: { 'IOS_TESTING': 'happy testing' }
environment: { IOS_TESTING: 'happy testing' }
})

# add check the arguments
Expand Down Expand Up @@ -323,10 +323,10 @@ def test_clipbord

@@driver.set_clipboard(content: input)

# rubocop:disable Layout/LineLength,Style/AsciiComments
# rubocop:disable Layout/LineLength
# iOS 13??
# [Xcode] 2019-06-06 10:01:15.029776+0900 WebDriverAgentRunner-Runner[16270:2865385] [claims] Upload preparation for claim 248BF916-16D3-4341-AFC3-653E3A05CAFA completed with error: Error Domain=NSCocoaErrorDomain Code=256 "The file “2c4ee6c5be2695a3c528cde33df5228960042b03” couldn’t be opened." UserInfo={NSURL=file:///Users/kazu/Library/Developer/CoreSimulator/Devices/3D099C88-C162-494E-9260-D0ABCBB434B1/data/Library/Caches/com.apple.Pasteboard/eb77e5f8f043896faf63b5041f0fbd121db984dd/2c4ee6c5be2695a3c528cde33df5228960042b03, NSFilePath=/Users/kazu/Library/Developer/CoreSimulator/Devices/3D099C88-C162-494E-9260-D0ABCBB434B1/data/Library/Caches/com.apple.Pasteboard/eb77e5f8f043896faf63b5041f0fbd121db984dd/2c4ee6c5be2695a3c528cde33df5228960042b03, NSUnderlyingError=0x600003855dd0 {Error Domain=NSPOSIXErrorDomain Code=22 "Invalid argument"}}
# rubocop:enable Layout/LineLength,Style/AsciiComments
# rubocop:enable Layout/LineLength
assert_equal input, @@driver.get_clipboard # does not work
end

Expand Down
6 changes: 3 additions & 3 deletions test/functional/ios/ios/search_context_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,11 @@ def teardown
end

def test_uiautomation
if @@core.automation_name != :xcuitest
if @@core.automation_name == :xcuitest
assert true
else
e = @@driver.find_element :predicate, 'wdName == "Buttons"'
assert !e.name.nil?
else
assert true
end
end

Expand Down
4 changes: 2 additions & 2 deletions test/test_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ def self.mac2

# Require a simulator which OS version is 11.4, for example.
def ios(platform_name = :ios)
platform_version = '14.2'
platform_version = '14.5'
wda_port = wda_local_port

real_device = ENV['REAL'] ? true : false
Expand Down Expand Up @@ -225,7 +225,7 @@ def add_xctestrun(real_device, caps, xcode_org_id)
else
"#{build_product}/#{runnner_prefix}simulator#{xcode_sdk_version}-x86_64.xctestrun"
end
use_xctestrun_file = File.exist?(xctestrun_path) ? true : false
use_xctestrun_file = File.exist? xctestrun_path

if use_xctestrun_file
caps[:caps][:bootstrapPath] = build_product
Expand Down

0 comments on commit ad519ee

Please sign in to comment.