Skip to content

Commit ad519ee

Browse files
authored
chore: update rubocop (#341)
* chore: bump version to 5.0.0 rc5 * chore: update rubocop * update * ci: use Ruby 3 * bump macOS and xcode version
1 parent e13b0ef commit ad519ee

14 files changed

+123
-39
lines changed

.rubocop.yml

+89-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
AllCops:
2-
TargetRubyVersion: 2.4
2+
TargetRubyVersion: 2.6
33
Layout/LineLength:
44
Max: 128
55
Layout/RescueEnsureAlignment:
@@ -56,3 +56,91 @@ Style/ExplicitBlockArgument:
5656
Enabled: false
5757
Style/KeywordParametersOrder:
5858
Enabled: false
59+
Gemspec/DateAssignment:
60+
Enabled: true
61+
Layout/LineEndStringConcatenationIndentation:
62+
Enabled: true
63+
Layout/SpaceBeforeBrackets:
64+
Enabled: true
65+
Lint/AmbiguousAssignment:
66+
Enabled: true
67+
Lint/AmbiguousOperatorPrecedence:
68+
Enabled: false
69+
Lint/AmbiguousRange:
70+
Enabled: true
71+
Lint/DeprecatedConstants:
72+
Enabled: true
73+
Lint/DuplicateBranch:
74+
Enabled: true
75+
Lint/DuplicateRegexpCharacterClassElement:
76+
Enabled: true
77+
Lint/EmptyBlock:
78+
Enabled: true
79+
Lint/EmptyClass:
80+
Enabled: true
81+
Lint/EmptyInPattern:
82+
Enabled: true
83+
Lint/IncompatibleIoSelectWithFiberScheduler:
84+
Enabled: true
85+
Lint/LambdaWithoutLiteralBlock:
86+
Enabled: true
87+
Lint/NoReturnInBeginEndBlocks:
88+
Enabled: true
89+
Lint/NumberedParameterAssignment:
90+
Enabled: true
91+
Lint/OrAssignmentToConstant:
92+
Enabled: true
93+
Lint/RedundantDirGlobSort:
94+
Enabled: true
95+
Lint/RequireRelativeSelfPath:
96+
Enabled: true
97+
Lint/SymbolConversion:
98+
Enabled: true
99+
Lint/ToEnumArguments:
100+
Enabled: true
101+
Lint/TripleQuotes:
102+
Enabled: true
103+
Lint/UnexpectedBlockArity:
104+
Enabled: true
105+
Lint/UnmodifiedReduceAccumulator:
106+
Enabled: true
107+
Security/IoMethods:
108+
Enabled: true
109+
Style/ArgumentsForwarding:
110+
Enabled: true
111+
Style/CollectionCompact:
112+
Enabled: true
113+
Style/DocumentDynamicEvalDefinition:
114+
Enabled: true
115+
Style/EndlessMethod:
116+
Enabled: true
117+
Style/HashConversion:
118+
Enabled: true
119+
Style/HashExcept:
120+
Enabled: true
121+
Style/IfWithBooleanLiteralBranches:
122+
Enabled: true
123+
Style/InPatternThen:
124+
Enabled: true
125+
Style/MultilineInPatternThen:
126+
Enabled: true
127+
Style/NegatedIfElseCondition:
128+
Enabled: true
129+
Style/NilLambda:
130+
Enabled: true
131+
Style/NumberedParameters:
132+
Enabled: true
133+
Style/NumberedParametersLimit:
134+
Enabled: true
135+
Style/QuotedSymbols:
136+
Enabled: true
137+
Style/RedundantArgument:
138+
Enabled: true
139+
Style/RedundantSelfAssignmentBranch:
140+
Enabled: true
141+
Style/SelectByRegexp:
142+
Enabled: true
143+
Style/StringChars:
144+
Enabled: true
145+
Style/SwapValues:
146+
Enabled: true

appium_lib_core.gemspec

+1-1
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ Gem::Specification.new do |spec|
3131
spec.add_development_dependency 'minitest', '~> 5.0'
3232
spec.add_development_dependency 'minitest-reporters', '~> 1.1'
3333
spec.add_development_dependency 'webmock', '~> 3.14.0'
34-
spec.add_development_dependency 'rubocop', '1.12.1'
34+
spec.add_development_dependency 'rubocop', '1.22.1'
3535
spec.add_development_dependency 'appium_thor', '~> 1.0'
3636
spec.add_development_dependency 'pry'
3737
spec.add_development_dependency 'pry-byebug'

ci-jobs/functional/run_appium.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ steps:
1111
displayName: Installed node dependencies
1212
- task: UseRubyVersion@0
1313
inputs:
14-
versionSpec: '2.7'
14+
versionSpec: '3.0'
1515
- script: |
1616
mkdir -p test/report
1717
nohup appium --relaxed-security --log-timestamp --log-no-colors > test/report/appium.out 2>&1 &

ci-jobs/functional_test.yml

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
# jobs for functional test
22
parameters:
3-
vmImage: 'macOS-10.15'
4-
vmImageForIOS: 'macOS-10.15' # Not sure the reason, but macOS 10.14 instance raises no info.plist error
5-
xcodeForIOS: 12.2
6-
xcodeForTVOS: 12.2
3+
vmImage: 'macOS-11'
4+
vmImageForIOS: 'macOS-11'
5+
xcodeForIOS: 12.5.1
6+
xcodeForTVOS: 12.5.1
77
androidSDK: 29 # API Level 30 emulators are more unstable than 29
88
appiumVersion: 'beta'
99
ignoreVersionSkip: true

lib/appium_lib_core/common/base/bridge.rb

+5-7
Original file line numberDiff line numberDiff line change
@@ -187,8 +187,8 @@ def session_capabilities
187187

188188
# Port from MJSONWP
189189
def send_keys_to_active_element(key)
190-
text = ::Selenium::WebDriver::Keys.encode(key).join('')
191-
execute :send_keys_to_active_element, {}, { value: text.split(//) }
190+
text = ::Selenium::WebDriver::Keys.encode(key).join
191+
execute :send_keys_to_active_element, {}, { value: text.chars }
192192
end
193193

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

321321
Array(data).map do |l|
322-
begin
323-
::Selenium::WebDriver::LogEntry.new l.fetch('level', 'UNKNOWN'), l.fetch('timestamp'), l.fetch('message')
324-
rescue KeyError
325-
next
326-
end
322+
::Selenium::WebDriver::LogEntry.new l.fetch('level', 'UNKNOWN'), l.fetch('timestamp'), l.fetch('message')
323+
rescue KeyError
324+
next
327325
end
328326
end
329327

lib/appium_lib_core/common/base/driver.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ def create_bridge(**opts)
8383
def update_sending_request_to(protocol:, host:, port:, path:)
8484
unless @bridge.http&.class&.method_defined? :update_sending_request_to
8585
::Appium::Logger.warn "#{@bridge.http&.class} has no 'update_sending_request_to'. " \
86-
'It keeps current connection target.'
86+
'It keeps current connection target.'
8787
return
8888
end
8989

lib/appium_lib_core/common/base/screenshot.rb

+2-2
Original file line numberDiff line numberDiff line change
@@ -63,8 +63,8 @@ def screenshot_as(format)
6363
def save_element_screenshot(element, png_path)
6464
extension = File.extname(png_path).downcase
6565
if extension != '.png'
66-
::Appium::Logger.warn 'name used for saved screenshot does not match file type. '\
67-
'It should end with .png extension'
66+
::Appium::Logger.warn 'name used for saved screenshot does not match file type. ' \
67+
'It should end with .png extension'
6868
end
6969
File.open(png_path, 'wb') { |f| f << element_screenshot_as(element, :png) }
7070
end

lib/appium_lib_core/common/device/value.rb

+2-2
Original file line numberDiff line numberDiff line change
@@ -39,11 +39,11 @@ def generate_value_and_text(*value)
3939
end
4040

4141
# Keep .split(//) for backward compatibility for now
42-
text = keys.join('')
42+
text = keys.join
4343

4444
# FIXME: further work for W3C. Over appium 1.15.0 or later
4545
# { value: text.split(//), text: text }
46-
{ value: text.split(//) }
46+
{ value: text.chars }
4747
end
4848
end # module Value
4949
end # module Device

lib/appium_lib_core/version.rb

+2-2
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414

1515
module Appium
1616
module Core
17-
VERSION = '5.0.0.rc4' unless defined? ::Appium::Core::VERSION
18-
DATE = '2021-10-14' unless defined? ::Appium::Core::DATE
17+
VERSION = '5.0.0.rc5' unless defined? ::Appium::Core::VERSION
18+
DATE = '2021-10-15' unless defined? ::Appium::Core::DATE
1919
end
2020
end

test/functional/android/android/device_data_test.rb

+2-2
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ def teardown
3131

3232
def test_push_and_pull_file
3333
file = 'aVZCT1J3MEtHZ29BQUF BTlNVaEVVZ0FBQXU0QUFB VTJDQUlBQUFCRnRhUl' \
34-
'JBQUFBQVhOU1IwSUFyczRjNlFBQQ0KQUJ4cFJFOVVBQUFBQWdBQUFBQUFBQUti'
34+
'JBQUFBQVhOU1IwSUFyczRjNlFBQQ0KQUJ4cFJFOVVBQUFBQWdBQUFBQUFBQUti'
3535
path = '/data/local/tmp/remote.txt'
3636
@@core.wait do
3737
@driver.push_file path, file
@@ -42,7 +42,7 @@ def test_push_and_pull_file
4242

4343
def test_pull_folder
4444
file = 'aVZCT1J3MEtHZ29BQUF BTlNVaEVVZ0FBQXU0QUFB VTJDQUlBQUFCRnRhUl' \
45-
'JBQUFBQVhOU1IwSUFyczRjNlFBQQ0KQUJ4cFJFOVVBQUFBQWdBQUFBQUFBQUti'
45+
'JBQUFBQVhOU1IwSUFyczRjNlFBQQ0KQUJ4cFJFOVVBQUFBQWdBQUFBQUFBQUti'
4646
path = '/data/local/tmp/remote.txt'
4747
@driver.push_file path, file
4848

test/functional/android/android/device_test.rb

+6-8
Original file line numberDiff line numberDiff line change
@@ -362,14 +362,12 @@ def scroll_to(text)
362362
[rid]
363363
end
364364
args.each_with_index do |arg, index|
365-
begin
366-
elem = @driver.find_element :uiautomator,
367-
'new UiScrollable(new UiSelector().scrollable(true).instance(0))' \
368-
".scrollIntoView(#{arg}.instance(0));"
369-
return elem
370-
rescue StandardError => e
371-
raise e if index == args.size - 1
372-
end
365+
elem = @driver.find_element :uiautomator,
366+
'new UiScrollable(new UiSelector().scrollable(true).instance(0))' \
367+
".scrollIntoView(#{arg}.instance(0));"
368+
return elem
369+
rescue StandardError => e
370+
raise e if index == args.size - 1
373371
end
374372
end
375373
end

test/functional/ios/ios/device_test.rb

+3-3
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,7 @@ def test_app_management
151151
{
152152
bundleId: 'com.example.apple-samplecode.UICatalog',
153153
arguments: %w(arg1 arg2),
154-
environment: { 'IOS_TESTING': 'happy testing' }
154+
environment: { IOS_TESTING: 'happy testing' }
155155
})
156156

157157
# add check the arguments
@@ -323,10 +323,10 @@ def test_clipbord
323323

324324
@@driver.set_clipboard(content: input)
325325

326-
# rubocop:disable Layout/LineLength,Style/AsciiComments
326+
# rubocop:disable Layout/LineLength
327327
# iOS 13??
328328
# [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"}}
329-
# rubocop:enable Layout/LineLength,Style/AsciiComments
329+
# rubocop:enable Layout/LineLength
330330
assert_equal input, @@driver.get_clipboard # does not work
331331
end
332332

test/functional/ios/ios/search_context_test.rb

+3-3
Original file line numberDiff line numberDiff line change
@@ -29,11 +29,11 @@ def teardown
2929
end
3030

3131
def test_uiautomation
32-
if @@core.automation_name != :xcuitest
32+
if @@core.automation_name == :xcuitest
33+
assert true
34+
else
3335
e = @@driver.find_element :predicate, 'wdName == "Buttons"'
3436
assert !e.name.nil?
35-
else
36-
assert true
3737
end
3838
end
3939

test/test_helper.rb

+2-2
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ def self.mac2
121121

122122
# Require a simulator which OS version is 11.4, for example.
123123
def ios(platform_name = :ios)
124-
platform_version = '14.2'
124+
platform_version = '14.5'
125125
wda_port = wda_local_port
126126

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

230230
if use_xctestrun_file
231231
caps[:caps][:bootstrapPath] = build_product

0 commit comments

Comments
 (0)