Skip to content

Commit 4362aa1

Browse files
committed
[rb] update to latest rubocop and fix issues
1 parent 994ab87 commit 4362aa1

File tree

10 files changed

+36
-20
lines changed

10 files changed

+36
-20
lines changed

rb/.rubocop.yml

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -354,6 +354,22 @@ RSpec/VerifiedDoubleReference: # new in 2.10.0
354354
RSpec/FactoryBot/SyntaxMethods: # new in 2.7
355355
Enabled: true
356356
RSpec/Rails/AvoidSetupHook: # new in 2.4
357-
Enabled: true
357+
Enabled: false
358358
Style/EnvHome: # new in 1.29
359359
Enabled: true
360+
Layout/LineContinuationLeadingSpace: # new in 1.31
361+
Enabled: true
362+
Layout/LineContinuationSpacing: # new in 1.31
363+
Enabled: true
364+
Lint/ConstantOverwrittenInRescue: # new in 1.31
365+
Enabled: true
366+
Lint/NonAtomicFileOperation: # new in 1.31
367+
Enabled: true
368+
Style/MapCompactWithConditionalBlock: # new in 1.30
369+
Enabled: true
370+
RSpec/ChangeByZero: # new in 2.11.0
371+
Enabled: true
372+
RSpec/Capybara/SpecificMatcher: # new in 2.12
373+
Enabled: false
374+
RSpec/Rails/HaveHttpStatus: # new in 2.12
375+
Enabled: false

rb/lib/selenium/server.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ def download(required_version = :latest)
9292
download_server(redirected, destination)
9393
end
9494
rescue StandardError
95-
FileUtils.rm download_file_name if File.exist? download_file_name
95+
FileUtils.rm_rf download_file_name
9696
raise
9797
end
9898

rb/lib/selenium/webdriver/common/takes_screenshot.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ module TakesScreenshot
3232
def save_screenshot(png_path, full_page: false)
3333
extension = File.extname(png_path).downcase
3434
if extension != '.png'
35-
WebDriver.logger.warn "name used for saved screenshot does not match file type. "\
35+
WebDriver.logger.warn "name used for saved screenshot does not match file type. " \
3636
"It should end with .png extension",
3737
id: :screenshot
3838
end

rb/lib/selenium/webdriver/common/window.rb

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,8 @@ def initialize(bridge)
3636

3737
def size=(dimension)
3838
unless dimension.respond_to?(:width) && dimension.respond_to?(:height)
39-
raise ArgumentError, "expected #{dimension.inspect}:#{dimension.class}" \
40-
' to respond to #width and #height'
39+
raise ArgumentError, "expected #{dimension.inspect}:#{dimension.class} " \
40+
'to respond to #width and #height'
4141
end
4242

4343
@bridge.resize_window dimension.width, dimension.height
@@ -61,8 +61,8 @@ def size
6161

6262
def position=(point)
6363
unless point.respond_to?(:x) && point.respond_to?(:y)
64-
raise ArgumentError, "expected #{point.inspect}:#{point.class}" \
65-
' to respond to #x and #y'
64+
raise ArgumentError, "expected #{point.inspect}:#{point.class} " \
65+
'to respond to #x and #y'
6666
end
6767

6868
@bridge.reposition_window point.x, point.y
@@ -86,8 +86,8 @@ def position
8686

8787
def rect=(rectangle)
8888
unless %w[x y width height].all? { |val| rectangle.respond_to? val }
89-
raise ArgumentError, "expected #{rectangle.inspect}:#{rectangle.class}" \
90-
' to respond to #x, #y, #width, and #height'
89+
raise ArgumentError, "expected #{rectangle.inspect}:#{rectangle.class} " \
90+
'to respond to #x, #y, #width, and #height'
9191
end
9292

9393
@bridge.set_window_rect(x: rectangle.x,

rb/lib/selenium/webdriver/common/zipper.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ def unzip(path)
4141
to = File.join(destination, entry.name)
4242
dirname = File.dirname(to)
4343

44-
FileUtils.mkdir_p dirname unless File.exist? dirname
44+
FileUtils.mkdir_p dirname
4545
zip.extract(entry, to)
4646
end
4747
end

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -426,8 +426,8 @@ def clear_element(element)
426426

427427
def submit_element(element)
428428
script = "var form = arguments[0];\n" \
429-
"while (form.nodeName != \"FORM\" && form.parentNode) {\n" \
430-
" form = form.parentNode;\n" \
429+
"while (form.nodeName != \"FORM\" && form.parentNode) {\n " \
430+
"form = form.parentNode;\n" \
431431
"}\n" \
432432
"if (!form) { throw Error('Unable to find containing form element'); }\n" \
433433
"if (!form.ownerDocument) { throw Error('Unable to find owning document'); }\n" \

rb/selenium-webdriver.gemspec

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -56,10 +56,10 @@ Gem::Specification.new do |s|
5656
s.add_development_dependency 'rack', ['~> 2.0']
5757
s.add_development_dependency 'rake'
5858
s.add_development_dependency 'rspec', ['~> 3.0']
59-
s.add_development_dependency 'rubocop', ['~> 1.22']
60-
s.add_development_dependency 'rubocop-performance'
59+
s.add_development_dependency 'rubocop', ['~> 1.31']
60+
s.add_development_dependency 'rubocop-performance', ['~> 1.13']
6161
s.add_development_dependency 'rubocop-rake'
62-
s.add_development_dependency 'rubocop-rspec'
62+
s.add_development_dependency 'rubocop-rspec', ['~> 2.12']
6363
s.add_development_dependency 'webmock', ['~> 3.5']
6464
s.add_development_dependency 'webrick', ['~> 1.7']
6565
s.add_development_dependency 'yard', ['~> 0.9.11']

rb/spec/integration/selenium/webdriver/chrome/driver_spec.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ module Chrome
8484
expect(File.exist?(path)).to be true
8585
expect(File.size(path)).to be_positive
8686
ensure
87-
File.delete(path) if File.exist?(path)
87+
FileUtils.rm_rf(path)
8888
end
8989
end
9090
end

rb/spec/integration/selenium/webdriver/firefox/driver_spec.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ module Firefox
6060
end
6161

6262
ensure
63-
File.delete(path) if File.exist?(path)
63+
FileUtils.rm_rf(path)
6464
end
6565
end
6666

rb/spec/integration/selenium/webdriver/takes_screenshot_spec.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ module WebDriver
3535

3636
it 'should warn if extension of provided path is not png' do
3737
jpg_path = "#{Dir.tmpdir}/test#{SecureRandom.urlsafe_base64}.jpg"
38-
message = "name used for saved screenshot does not match file type. "\
38+
message = "name used for saved screenshot does not match file type. " \
3939
"It should end with .png extension"
4040
expect(WebDriver.logger).to receive(:warn).with(message, id: :screenshot).twice
4141

@@ -68,7 +68,7 @@ def save_screenshot_and_assert(source, path)
6868
expect(File.exist?(path)).to be true
6969
expect(File.size(path)).to be_positive
7070
ensure
71-
File.delete(path) if File.exist?(path)
71+
FileUtils.rm_rf(path)
7272
end
7373

7474
describe 'page size' do
@@ -77,7 +77,7 @@ def save_screenshot_and_assert(source, path)
7777
end
7878

7979
after do
80-
File.delete(path) if File.exist?(path)
80+
FileUtils.rm_rf(path)
8181
end
8282

8383
it 'takes viewport screenshot by default' do

0 commit comments

Comments
 (0)