Skip to content

Commit b3a689b

Browse files
committed
[rb] update with latest rubocop
1 parent c6d02f3 commit b3a689b

File tree

18 files changed

+41
-67
lines changed

18 files changed

+41
-67
lines changed

rb/.rubocop.yml

+15-2
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ require:
44

55
AllCops:
66
TargetRubyVersion: 2.5
7+
Exclude:
8+
- 'lib/selenium/webdriver/devtools/**/*'
79

810
Layout/EmptyLinesAroundAttributeAccessor:
911
Enabled: true
@@ -40,8 +42,9 @@ Lint/SuppressedException:
4042
Enabled: false
4143

4244
Metrics/AbcSize:
43-
Max: 27
45+
Max: 28
4446
Exclude:
47+
- 'lib/selenium/webdriver/remote/capabilities.rb'
4548
- 'lib/selenium/webdriver/remote/http/curb.rb'
4649
- 'lib/selenium/webdriver/support/color.rb'
4750

@@ -62,6 +65,7 @@ Metrics/CyclomaticComplexity:
6265
Max: 9
6366
Exclude:
6467
- 'lib/selenium/webdriver/remote/capabilities.rb'
68+
- 'lib/selenium/webdriver/support/color.rb'
6569

6670
Metrics/MethodLength:
6771
CountComments: false
@@ -82,7 +86,7 @@ Metrics/ParameterLists:
8286

8387
# TODO: Refactor Chrome::Bridge#create_capabilities
8488
Metrics/PerceivedComplexity:
85-
Max: 8
89+
Max: 9
8690
Exclude:
8791
- 'lib/selenium/webdriver/remote/capabilities.rb'
8892

@@ -132,6 +136,12 @@ RSpec/MessageSpies:
132136
RSpec/MultipleExpectations:
133137
Enabled: false
134138

139+
RSpec/StubbedMock:
140+
Enabled: false
141+
142+
RSpec/MultipleMemoizedHelpers:
143+
Enabled: false
144+
135145
Style/Alias:
136146
EnforcedStyle: prefer_alias_method
137147

@@ -165,6 +175,9 @@ Style/HashTransformValues:
165175
Style/NumericLiterals:
166176
Enabled: false
167177

178+
Style/OptionalBooleanParameter:
179+
Enabled: false
180+
168181
Style/RegexpLiteral:
169182
EnforcedStyle: mixed
170183

rb/lib/selenium/server.rb

+2-26
Original file line numberDiff line numberDiff line change
@@ -139,31 +139,7 @@ def net_http_start(address, &block)
139139
# :standalone, #hub, #node
140140
#
141141

142-
attr_accessor :role
143-
144-
#
145-
# The server port
146-
#
147-
148-
attr_accessor :port
149-
150-
#
151-
# The server timeout
152-
#
153-
154-
attr_accessor :timeout
155-
156-
#
157-
# Whether to launch the server in the background
158-
#
159-
160-
attr_accessor :background
161-
162-
#
163-
# Path to log file, or 'true' for stdout.
164-
#
165-
166-
attr_accessor :log
142+
attr_accessor :role, :port, :timeout, :background, :log
167143

168144
#
169145
# @param [String] jar Path to the server jar.
@@ -225,7 +201,7 @@ def <<(arg)
225201
private
226202

227203
def selenium4?
228-
@jar.match?(/[^\.][4]\./) || @jar.include?('deploy')
204+
@jar.match?(/[^.]4\./) || @jar.include?('deploy')
229205
end
230206

231207
def stop_process

rb/lib/selenium/webdriver/chrome/service.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ class Service < WebDriver::Service
3232

3333
private
3434

35-
# Note: This processing is deprecated
35+
# NOTE: This processing is deprecated
3636
def extract_service_args(driver_opts)
3737
driver_args = super
3838
driver_opts = driver_opts.dup

rb/lib/selenium/webdriver/common/driver.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -298,7 +298,7 @@ def ref; end
298298
def create_bridge(**opts)
299299
opts[:url] ||= service_url(opts)
300300
caps = opts.delete(:capabilities)
301-
# Note: This is deprecated
301+
# NOTE: This is deprecated
302302
cap_array = caps.is_a?(Hash) ? [caps] : Array(caps)
303303

304304
desired_capabilities = opts.delete(:desired_capabilities)

rb/lib/selenium/webdriver/common/service_manager.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ def find_free_port
103103

104104
def start_process
105105
@process = build_process(@executable_path, "--port=#{@port}", *@extra_args)
106-
# Note: this is a bug only in Windows 7
106+
# NOTE: this is a bug only in Windows 7
107107
@process.leader = true unless Platform.windows?
108108
@process.start
109109
end

rb/lib/selenium/webdriver/common/target_locator.rb

+4-4
Original file line numberDiff line numberDiff line change
@@ -57,10 +57,10 @@ def parent_frame
5757
def window(id)
5858
if block_given?
5959
original = begin
60-
@bridge.window_handle
61-
rescue Error::NoSuchWindowError
62-
nil
63-
end
60+
@bridge.window_handle
61+
rescue Error::NoSuchWindowError
62+
nil
63+
end
6464

6565
unless @bridge.window_handles.include? id
6666
raise Error::NoSuchWindowError, "The specified identifier '#{id}' is not found in the window handle list"

rb/lib/selenium/webdriver/edge_html/service.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ class Service < WebDriver::Service
3131

3232
private
3333

34-
# Note: This processing is deprecated
34+
# NOTE: This processing is deprecated
3535
def extract_service_args(driver_opts)
3636
driver_args = super
3737
driver_opts = driver_opts.dup

rb/lib/selenium/webdriver/firefox/service.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ class Service < WebDriver::Service
3232

3333
private
3434

35-
# Note: This processing is deprecated
35+
# NOTE: This processing is deprecated
3636
def extract_service_args(driver_opts)
3737
driver_args = super
3838
driver_opts = driver_opts.dup

rb/lib/selenium/webdriver/ie/service.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ class Service < WebDriver::Service
3232

3333
private
3434

35-
# Note: This processing is deprecated
35+
# NOTE: This processing is deprecated
3636
def extract_service_args(driver_opts)
3737
driver_args = super
3838
driver_opts = driver_opts.dup

rb/lib/selenium/webdriver/remote/bridge.rb

+2-2
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ class Bridge
3535
# @api private
3636
#
3737

38-
def initialize(http_client: nil, url:)
38+
def initialize(url:, http_client: nil)
3939
uri = url.is_a?(URI) ? url : URI.parse(url)
4040
uri.path += '/' unless uri.path.end_with?('/')
4141

@@ -624,7 +624,7 @@ def convert_locator(how, what)
624624
[how, what]
625625
end
626626

627-
ESCAPE_CSS_REGEXP = /(['"\\#.:;,!?+<>=~*^$|%&@`{}\-\[\]\(\)])/.freeze
627+
ESCAPE_CSS_REGEXP = /(['"\\#.:;,!?+<>=~*^$|%&@`{}\-\[\]()])/.freeze
628628
UNICODE_CODE_POINT = 30
629629

630630
# Escapes invalid characters in CSS selector.

rb/lib/selenium/webdriver/remote/http/default.rb

+2-2
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,7 @@ module Http
2828
class Default < Common
2929
attr_writer :proxy
3030

31-
attr_accessor :open_timeout
32-
attr_accessor :read_timeout
31+
attr_accessor :open_timeout, :read_timeout
3332

3433
# Initializes object.
3534
# Warning: Setting {#open_timeout} to non-nil values will cause a separate thread to spawn.
@@ -39,6 +38,7 @@ class Default < Common
3938
def initialize(open_timeout: nil, read_timeout: nil)
4039
@open_timeout = open_timeout
4140
@read_timeout = read_timeout
41+
super()
4242
end
4343

4444
def close

rb/lib/selenium/webdriver/safari/options.rb

-16
Original file line numberDiff line numberDiff line change
@@ -37,22 +37,6 @@ class Options < WebDriver::Options
3737
@options[key] = value
3838
end
3939
end
40-
41-
#
42-
# Create a new Options instance for W3C-capable versions of Safari.
43-
#
44-
# @example
45-
# options = Selenium::WebDriver::Safari::Options.new(automatic_inspection: true)
46-
# driver = Selenium::WebDriver.for :safari, options: options
47-
#
48-
# @param [Hash] opts the pre-defined options to create the Safari::Options with
49-
# @option opts [Boolean] :automatic_inspection Preloads Web Inspector and JavaScript debugger. Default is false
50-
# @option opts [Boolean] :automatic_profiling Preloads Web Inspector and starts a timeline recording. Default is false
51-
#
52-
53-
def initialize(**opts)
54-
super
55-
end
5640
end # Options
5741
end # Safari
5842
end # WebDriver

rb/lib/selenium/webdriver/support/block_event_listener.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ def initialize(callback)
2525
@callback = callback
2626
end
2727

28-
def method_missing(meth, *args) # rubocop:disable Style/MethodMissingSuper, Style/MissingRespondToMissing
28+
def method_missing(meth, *args) # rubocop:disable Style/MissingRespondToMissing
2929
@callback.call meth, *args
3030
end
3131
end # BlockEventListener

rb/lib/selenium/webdriver/support/event_firing_bridge.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ def dispatch(name, *args)
120120
returned
121121
end
122122

123-
def method_missing(meth, *args, &blk) # rubocop:disable Style/MethodMissingSuper, Style/MissingRespondToMissing
123+
def method_missing(meth, *args, &blk) # rubocop:disable Style/MissingRespondToMissing
124124
@delegate.__send__(meth, *args, &blk)
125125
end
126126
end # EventFiringBridge

rb/selenium-webdriver.gemspec

+3-3
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ Gem::Specification.new do |s|
2828
s.required_rubygems_version = Gem::Requirement.new('> 1.3.1') if s.respond_to? :required_rubygems_version=
2929
s.required_ruby_version = Gem::Requirement.new('>= 2.5')
3030

31-
s.files = Dir[root + '/**/*'].reject { |e| e =~ /ruby\.iml|build\.desc/ }.map { |e| e.sub(root + '/', '') }
31+
s.files = Dir["#{root}/**/*"].reject { |e| e =~ /ruby\.iml|build\.desc/ }.map { |e| e.sub("#{root}/", '') }
3232
s.require_paths = ['lib']
3333

3434
s.add_runtime_dependency 'childprocess', ['>= 0.5', '< 5.0']
@@ -41,10 +41,10 @@ Gem::Specification.new do |s|
4141
s.add_development_dependency 'rack', ['~> 2.0']
4242
s.add_development_dependency 'rake'
4343
s.add_development_dependency 'rspec', ['~> 3.0']
44-
s.add_development_dependency 'rubocop', ['~> 0.84.0']
44+
s.add_development_dependency 'rubocop', ['~> 1.8.0']
4545
s.add_development_dependency 'rubocop-performance'
4646
s.add_development_dependency 'rubocop-rspec'
4747
s.add_development_dependency 'webmock', ['~> 3.5']
48-
s.add_development_dependency 'webrick',['~> 1.7']
48+
s.add_development_dependency 'webrick', ['~> 1.7']
4949
s.add_development_dependency 'yard', ['~> 0.9.11']
5050
end

rb/spec/integration/selenium/webdriver/spec_support/guards/guard.rb

+3-2
Original file line numberDiff line numberDiff line change
@@ -50,9 +50,10 @@ def message
5050
'no reason given'
5151
end
5252

53-
if @type == :exclude
53+
case @type
54+
when :exclude
5455
"Test not guarded because it breaks test run; #{details}"
55-
elsif @type == :exclusive
56+
when :exclusive
5657
'Test does not apply to this configuration'
5758
else
5859
"Test guarded; #{details}"

rb/spec/unit/selenium/webdriver/chrome/options_spec.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ module Chrome
8585
it 'adds an extension' do
8686
allow(File).to receive(:file?).and_return(true)
8787
ext = 'foo.crx'
88-
allow_any_instance_of(Options).to receive(:encode_file).with(ext).and_return("encoded_#{ext[/([^\.]*)/]}")
88+
allow_any_instance_of(Options).to receive(:encode_file).with(ext).and_return("encoded_#{ext[/([^.]*)/]}")
8989

9090
options.add_extension(ext)
9191
expect(options.extensions).to eq([ext])

rb/spec/unit/selenium/webdriver/edge_chrome/options_spec.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ module EdgeChrome
8585
it 'adds an extension' do
8686
allow(File).to receive(:file?).and_return(true)
8787
ext = 'foo.crx'
88-
allow_any_instance_of(Options).to receive(:encode_file).with(ext).and_return("encoded_#{ext[/([^\.]*)/]}")
88+
allow_any_instance_of(Options).to receive(:encode_file).with(ext).and_return("encoded_#{ext[/([^.]*)/]}")
8989

9090
options.add_extension(ext)
9191
expect(options.extensions).to eq([ext])

0 commit comments

Comments
 (0)