Skip to content

Commit e13c58f

Browse files
authored
feat: bump rubocop (#293)
1 parent b9dbd61 commit e13c58f

21 files changed

+49
-41
lines changed

.rubocop.yml

+18-4
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,15 @@
11
AllCops:
22
TargetRubyVersion: 2.4
3-
Metrics/LineLength:
3+
Layout/LineLength:
44
Max: 128
5+
Layout/RescueEnsureAlignment:
6+
Enabled: false
7+
Layout/EmptyLinesAroundAttributeAccessor:
8+
Enabled: false
9+
Layout/EmptyLineBetweenDefs:
10+
Enabled: false
11+
Layout/HashAlignment:
12+
Enabled: false
513
Metrics/MethodLength:
614
Enabled: false
715
Metrics/ModuleLength:
@@ -26,8 +34,6 @@ Style/CommentedKeyword:
2634
Enabled: false
2735
Style/PercentLiteralDelimiters:
2836
Enabled: false
29-
Style/BracesAroundHashParameters:
30-
Enabled: false
3137
Style/SymbolArray:
3238
Enabled: false
3339
Style/UnpackFirst:
@@ -40,5 +46,13 @@ Naming/MemoizedInstanceVariableName:
4046
- test/**/*
4147
Naming/RescuedExceptionsVariableName:
4248
Enabled: false
43-
Layout/RescueEnsureAlignment:
49+
Style/CaseLikeIf:
50+
Enabled: false
51+
Style/RedundantRegexpEscape:
52+
Enabled: false
53+
Style/OptionalBooleanParameter:
54+
Enabled: false
55+
Style/ExplicitBlockArgument:
56+
Enabled: false
57+
Style/KeywordParametersOrder:
4458
Enabled: false

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.11.0'
34-
spec.add_development_dependency 'rubocop', '0.68.1'
34+
spec.add_development_dependency 'rubocop', '1.6.1'
3535
spec.add_development_dependency 'appium_thor', '~> 1.0'
3636
spec.add_development_dependency 'pry'
3737
spec.add_development_dependency 'pry-byebug'

lib/appium_lib_core.rb

+5-5
Original file line numberDiff line numberDiff line change
@@ -34,11 +34,11 @@ def self.symbolize_keys(hash)
3434

3535
hash.each_with_object({}) do |pair, acc|
3636
key = begin
37-
pair[0].to_sym
38-
rescue StandardError => e
39-
::Appium::Logger.warn(e.message)
40-
pair[0]
41-
end
37+
pair[0].to_sym
38+
rescue StandardError => e
39+
::Appium::Logger.warn(e.message)
40+
pair[0]
41+
end
4242

4343
value = pair[1]
4444
acc[key] = value.is_a?(Hash) ? symbolize_keys(value) : value

lib/appium_lib_core/android/device.rb

+2-2
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ module Android
2525
module Device
2626
extend Forwardable
2727

28-
# rubocop:disable Metrics/LineLength
28+
# rubocop:disable Layout/LineLength
2929

3030
# @!method open_notifications
3131
# Open Android notifications
@@ -307,7 +307,7 @@ module Device
307307
## class << self
308308
####
309309

310-
# rubocop:enable Metrics/LineLength
310+
# rubocop:enable Layout/LineLength
311311

312312
class << self
313313
def extended(_mod)

lib/appium_lib_core/common/base/http_default.rb

+2-1
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,8 @@ class Default < Selenium::WebDriver::Remote::Http::Default
3636

3737
attr_reader :additional_headers
3838

39-
def initialize(open_timeout: nil, read_timeout: nil)
39+
# override
40+
def initialize(open_timeout: nil, read_timeout: nil) # rubocop:disable Lint/MissingSuper
4041
@open_timeout = open_timeout
4142
@read_timeout = read_timeout
4243
@additional_headers = {}

lib/appium_lib_core/common/base/search_context.rb

+2-4
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ class Base
1818
module SearchContext
1919
# referenced: ::Selenium::WebDriver::SearchContext
2020

21-
# rubocop:disable Layout/AlignHash
2221
FINDERS = ::Selenium::WebDriver::SearchContext::FINDERS.merge(
2322
accessibility_id: 'accessibility id',
2423
image: '-image',
@@ -37,9 +36,8 @@ module SearchContext
3736
# Tizen with Tizen prefix
3837
tizen_uiautomation: '-tizen uiautomation'
3938
)
40-
# rubocop:enable Layout/AlignHash
4139

42-
# rubocop:disable Metrics/LineLength
40+
# rubocop:disable Layout/LineLength
4341
#
4442
# Find the first element matching the given arguments
4543
#
@@ -129,7 +127,7 @@ module SearchContext
129127
# # For Tizen
130128
# @driver.find_elements :tizen_uiautomation, '....'
131129
#
132-
# rubocop:enable Metrics/LineLength
130+
# rubocop:enable Layout/LineLength
133131
def find_element(*args)
134132
how, what = extract_args(args)
135133
by = _set_by_from_finders(how)

lib/appium_lib_core/common/command/common.rb

-2
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
1414

15-
# rubocop:disable Layout/AlignHash
1615
module Appium
1716
module Core
1817
# ref: https://github.com/appium/appium-base-driver/blob/master/lib/mjsonwp/routes.js
@@ -109,4 +108,3 @@ module Commands
109108
end # module Commands
110109
end # module Core
111110
end # module Appium
112-
# rubocop:enable Layout/AlignHash

lib/appium_lib_core/common/command/mjsonwp.rb

-2
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
1414

15-
# rubocop:disable Layout/AlignHash
1615
module Appium
1716
module Core
1817
module Commands
@@ -27,4 +26,3 @@ module MJSONWP
2726
end # module Commands
2827
end # module Core
2928
end # Appium
30-
# rubocop:enable Layout/AlignHash

lib/appium_lib_core/common/command/w3c.rb

-2
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
1414

15-
# rubocop:disable Layout/AlignHash
1615
module Appium
1716
module Core
1817
module Commands
@@ -55,4 +54,3 @@ module W3C
5554
end # module Commands
5655
end # module Core
5756
end # module Appium
58-
# rubocop:enable Layout/AlignHash

lib/appium_lib_core/common/device/app_management.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ def app_strings(language = nil)
3434
execute :app_strings, {}, opts
3535
end
3636

37-
def background_app(duration = 0) # rubocop:disable Lint/UnusedMethodArgument
37+
def background_app(duration = 0)
3838
# Should override in each driver
3939
raise NotImplementedError
4040
end

lib/appium_lib_core/common/wait.rb

+2-2
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ def until(timeout: DEFAULT_TIMEOUT, interval: DEFAULT_INTERVAL, message: nil, ig
5353
return yield(object)
5454
rescue ::Errno::ECONNREFUSED => e
5555
raise e
56-
rescue *ignored => last_error # rubocop:disable Lint/HandleExceptions
56+
rescue *ignored => last_error
5757
# swallowed
5858
end
5959
sleep interval
@@ -98,7 +98,7 @@ def until_true(timeout: DEFAULT_TIMEOUT, interval: DEFAULT_INTERVAL, message: ni
9898
return result if result
9999
rescue ::Errno::ECONNREFUSED => e
100100
raise e
101-
rescue *ignored => last_error # rubocop:disable Lint/HandleExceptions
101+
rescue *ignored => last_error
102102
# swallowed
103103
end
104104
sleep interval

lib/appium_lib_core/ios/xcuitest/device.rb

+2-2
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ module Xcuitest
2323
module Device
2424
extend Forwardable
2525

26-
# rubocop:disable Metrics/LineLength
26+
# rubocop:disable Layout/LineLength
2727

2828
# @!method hide_keyboard(close_key = nil, strategy = nil)
2929
# Hide the onscreen keyboard
@@ -171,7 +171,7 @@ module Device
171171
# @driver.battery_info #=> { state: :full, level: 0.7 }
172172
#
173173

174-
# rubocop:enable Metrics/LineLength
174+
# rubocop:enable Layout/LineLength
175175

176176
####
177177
## class << self

lib/appium_lib_core/windows/device.rb

+2-2
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ module Windows
2020
module Device
2121
extend Forwardable
2222

23-
# rubocop:disable Metrics/LineLength
23+
# rubocop:disable Layout/LineLength
2424

2525
# @since Appium 1.18.0
2626
# @!method start_recording_screen(remote_path: nil, user: nil, pass: nil, method: 'PUT', force_restart: nil, time_limit: nil, fps: nil, preset: nil, video_filter: nil, capture_clicks: nil, capture_cursor: nil, audio_input: nil)
@@ -69,7 +69,7 @@ module Device
6969
# @driver.start_recording_screen capture_cursor: true, capture_clicks: true, time_limit: '260'
7070
#
7171

72-
# rubocop:enable Metrics/LineLength
72+
# rubocop:enable Layout/LineLength
7373

7474
####
7575
## class << self

script/commands.rb

+3-3
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,9 @@
1717

1818
module Script
1919
class CommandsChecker
20-
attr_reader :spec_commands
21-
attr_reader :implemented_mjsonwp_commands, :implemented_w3c_commands, :implemented_core_commands
22-
attr_reader :webdriver_oss_commands, :webdriver_w3c_commands
20+
attr_reader :spec_commands,
21+
:implemented_mjsonwp_commands, :implemented_w3c_commands, :implemented_core_commands,
22+
:webdriver_oss_commands, :webdriver_w3c_commands
2323

2424
# Set commands implemented in this core library.
2525
#

test/functional/android/android/device_test.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -380,7 +380,7 @@ def resource_id(string, on_match)
380380
unquote = string.match(/"(.+)"/)
381381
string = unquote[1] if unquote
382382

383-
resource_id = %r{^[a-zA-Z_][a-zA-Z0-9\._]*:[^\/]+\/[\S]+$}
383+
resource_id = %r{^[a-zA-Z_][a-zA-Z0-9._]*:[^\/]+\/\S+$}
384384
string.match(resource_id) ? on_match : ''
385385
end
386386

test/functional/android/webdriver/w3c_actions_test.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,7 @@ def _uiautomator2_do_actions_with_many_down_up(element, rect)
159159
::Selenium::WebDriver::Error::InvalidArgumentError].include? error.class
160160
end
161161

162-
# Note: Works with Espresso Driver
162+
# NOTE: Works with Espresso Driver
163163
def test_multiple_actions
164164
skip_as_appium_version '1.8.0'
165165

test/functional/ios/ios/device_test.rb

+2-2
Original file line numberDiff line numberDiff line change
@@ -322,10 +322,10 @@ def test_clipbord
322322

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

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

test/functional/ios/ios/mjpeg_server_test.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ def test_start_recording_screen
5050
assert File.exist? to_path
5151
end
5252

53-
def test_start_recording_screen_2
53+
def test_start_recording_screen2
5454
skip_as_appium_version '1.9.2'
5555

5656
to_path = 'recorded_file_ios_2.mp4'

test/functional/mac2/driver_test.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ def teardown
2626
save_reports(@driver)
2727
end
2828

29-
def test_1
29+
def test_first
3030
@driver.page_source
3131
e = @driver.find_element :name, 'Apple'
3232
e.click

test/test_helper.rb

+2-2
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626

2727
begin
2828
Minitest::Reporters.use! [Minitest::Reporters::ProgressReporter.new, Minitest::Reporters::JUnitReporter.new]
29-
rescue Errno::ENOENT # rubocop:disable Lint/HandleExceptions
29+
rescue Errno::ENOENT
3030
# Ignore since Minitest::Reporters::JUnitReporter.new fails in deleting files, sometimes
3131
end
3232

@@ -204,7 +204,7 @@ def device_name(os_version, platform_name, wda_local_port)
204204

205205
# for use_xctestrun_file
206206
def add_xctestrun(real_device, caps, xcode_org_id)
207-
xcode_sdk_version = /iPhoneOS([0-9\.]+)\.sdk/.match(`xcodebuild -version -sdk`)[1]
207+
xcode_sdk_version = /iPhoneOS([0-9.]+)\.sdk/.match(`xcodebuild -version -sdk`)[1]
208208

209209
derived_data_path = File.expand_path("tmp/#{xcode_org_id}") # Can run in parallel if we set here as a unique path
210210
FileUtils.mkdir_p(derived_data_path) unless File.exist? derived_data_path

test/unit/driver_test.rb

+1
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ def setup
2525
class ExampleDriver
2626
# for test
2727
attr_reader :core
28+
2829
def initialize(opts)
2930
@core = ::Appium::Core.for(opts)
3031
end

0 commit comments

Comments
 (0)