Skip to content

Commit

Permalink
Update rubocop and remove unnecessary overrides [rb]
Browse files Browse the repository at this point in the history
  • Loading branch information
twalpole committed Jul 13, 2019
1 parent 95645b8 commit f2c647a
Show file tree
Hide file tree
Showing 17 changed files with 27 additions and 42 deletions.
24 changes: 2 additions & 22 deletions rb/.rubocop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,6 @@ require:
AllCops:
TargetRubyVersion: 2.4

Naming/RescuedExceptionsVariableName:
Enabled: false

Layout/SpaceInsideHashLiteralBraces:
EnforcedStyle: no_space

Expand All @@ -23,11 +20,6 @@ Style/Alias:
Lint/HandleExceptions:
Enabled: false

Style/PercentLiteralDelimiters:
PreferredDelimiters:
'%i': '[]'
'%w': '[]'

Style/RegexpLiteral:
EnforcedStyle: mixed

Expand Down Expand Up @@ -88,15 +80,10 @@ Metrics/AbcSize:

Metrics/LineLength:
Max: 130
Exclude:
- 'lib/selenium/webdriver/remote/capabilities.rb'
- 'lib/selenium/webdriver/remote/bridge.rb'
- 'lib/selenium/webdriver/ie/service.rb'
- 'spec/unit/selenium/server_spec.rb'
- 'spec/integration/selenium/webdriver/timeout_spec.rb'
IgnoredPatterns:
- '\s+# rubocop'
- '^\s*#'
- '^\s*it .*, except: \{.*\} do$'

Metrics/ModuleLength:
CountComments: false
Expand All @@ -116,11 +103,7 @@ Metrics/BlockLength:
- 'selenium-webdriver.gemspec'

Metrics/ParameterLists:
Exclude:
- 'lib/selenium/webdriver/common/interactions/pointer_input.rb'

Layout/EmptyLineAfterMagicComment:
Enabled: false
CountKeywordArgs: false

Layout/EmptyLinesAroundClassBody:
Enabled: false
Expand All @@ -135,9 +118,6 @@ Style/Dir:
Exclude:
- 'selenium-webdriver.gemspec'

Style/RescueStandardError:
Enabled: false

RSpec/ExampleWording:
Enabled: false

Expand Down
2 changes: 1 addition & 1 deletion rb/lib/selenium/server.rb
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ def download(required_version)
raise Error, "#{resp.code} for #{download_file_name}" unless resp.is_a? Net::HTTPSuccess
end
end
rescue
rescue StandardError
FileUtils.rm download_file_name if File.exist? download_file_name
raise
end
Expand Down
4 changes: 2 additions & 2 deletions rb/lib/selenium/webdriver/common/port_prober.rb
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@ def self.free?(port)
Platform.interfaces.each do |host|
begin
TCPServer.new(host, port).close
rescue *IGNORED_ERRORS => ex
WebDriver.logger.debug("port prober could not bind to #{host}:#{port} (#{ex.message})")
rescue *IGNORED_ERRORS => e
WebDriver.logger.debug("port prober could not bind to #{host}:#{port} (#{e.message})")
# ignored - some machines appear unable to bind to some of their interfaces
end
end
Expand Down
4 changes: 2 additions & 2 deletions rb/lib/selenium/webdriver/common/socket_lock.rb
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,8 @@ def can_lock?
ChildProcess.close_on_exec @server

true
rescue SocketError, Errno::EADDRINUSE, Errno::EBADF => ex
WebDriver.logger.debug("#{self}: #{ex.message}")
rescue SocketError, Errno::EADDRINUSE, Errno::EBADF => e
WebDriver.logger.debug("#{self}: #{e.message}")
false
end

Expand Down
2 changes: 1 addition & 1 deletion rb/lib/selenium/webdriver/common/wait.rb
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ def until
begin
result = yield
return result if result
rescue *@ignored => last_error
rescue *@ignored => last_error # rubocop:disable Naming/RescuedExceptionsVariableName
# swallowed
end

Expand Down
10 changes: 5 additions & 5 deletions rb/lib/selenium/webdriver/ie/service.rb
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,11 @@ class Service < WebDriver::Service
def extract_service_args(driver_opts)
driver_args = super
driver_opts = driver_opts.dup
driver_args << "--log-level=#{driver_opts.delete(:log_level).to_s.upcase}" if driver_opts.key?(:log_level)
driver_args << "--log-file=#{driver_opts.delete(:log_file)}" if driver_opts.key?(:log_file)
driver_args << "--implementation=#{driver_opts.delete(:implementation).to_s.upcase}" if driver_opts.key?(:implementation)
driver_args << "--host=#{driver_opts.delete(:host)}" if driver_opts.key?(:host)
driver_args << "--extract_path=#{driver_opts.delete(:extract_path)}" if driver_opts.key?(:extract_path)
driver_args << "--log-level=#{driver_opts[:log_level].to_s.upcase}" if driver_opts.key?(:log_level)
driver_args << "--log-file=#{driver_opts[:log_file]}" if driver_opts.key?(:log_file)
driver_args << "--implementation=#{driver_opts[:implementation].to_s.upcase}" if driver_opts.key?(:implementation)
driver_args << "--host=#{driver_opts[:host]}" if driver_opts.key?(:host)
driver_args << "--extract_path=#{driver_opts[:extract_path]}" if driver_opts.key?(:extract_path)
driver_args << "--silent" if driver_opts[:silent] == true
driver_args
end
Expand Down
2 changes: 1 addition & 1 deletion rb/lib/selenium/webdriver/remote/bridge.rb
Original file line number Diff line number Diff line change
Expand Up @@ -631,7 +631,7 @@ def convert_locators(how, what)
# @see https://mathiasbynens.be/notes/css-escapes
def escape_css(string)
string = string.gsub(ESCAPE_CSS_REGEXP) { |match| "\\#{match}" }
string = "\\#{UNICODE_CODE_POINT + Integer(string[0])} #{string[1..-1]}" if !string.empty? && string[0].match?(/[[:digit:]]/)
string = "\\#{UNICODE_CODE_POINT + Integer(string[0])} #{string[1..-1]}" if string[0]&.match?(/[[:digit:]]/)

string
end
Expand Down
6 changes: 3 additions & 3 deletions rb/lib/selenium/webdriver/remote/http/default.rb
Original file line number Diff line number Diff line change
Expand Up @@ -89,15 +89,15 @@ def request(verb, url, headers, payload, redirects = 0)
retries += 1
sleep 2
retry
rescue Errno::EADDRNOTAVAIL => ex
rescue Errno::EADDRNOTAVAIL => e
# a retry is sometimes needed when the port becomes temporarily unavailable
raise if retries >= MAX_RETRIES

retries += 1
sleep 2
retry
rescue Errno::ECONNREFUSED => ex
raise ex.class, "using proxy: #{proxy.http}" if use_proxy?
rescue Errno::ECONNREFUSED => e
raise e.class, "using proxy: #{proxy.http}" if use_proxy?

raise
end
Expand Down
2 changes: 1 addition & 1 deletion rb/selenium-webdriver.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ Gem::Specification.new do |s|
s.add_development_dependency 'rack', ['~> 2.0']
s.add_development_dependency 'rake'
s.add_development_dependency 'rspec', ['~> 3.0']
s.add_development_dependency 'rubocop', ['~> 0.67.0']
s.add_development_dependency 'rubocop', ['~> 0.72.0']
s.add_development_dependency 'rubocop-performance'
s.add_development_dependency 'rubocop-rspec'
s.add_development_dependency 'webmock', ['~> 3.5']
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -158,10 +158,10 @@ def create_driver!(**opts, &block)
else
instance
end
rescue => ex
@create_driver_error = ex
rescue StandardError => e
@create_driver_error = e
@create_driver_error_count += 1
raise ex
raise e
end

private
Expand Down
7 changes: 6 additions & 1 deletion rb/spec/unit/selenium/server_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,12 @@ module Selenium
expect(File).to receive(:exist?).with('selenium-server-test.jar').and_return(true)

expect(ChildProcess).to receive(:build)
.with('java', '-Dwebdriver.chrome.driver=/bin/chromedriver', '-jar', 'selenium-server-test.jar', '-port', '4444', 'foo', 'bar')
.with('java',
'-Dwebdriver.chrome.driver=/bin/chromedriver',
'-jar', 'selenium-server-test.jar',
'-port', '4444',
'foo',
'bar')
.and_return(mock_process)

server = Selenium::Server.new('selenium-server-test.jar', background: true)
Expand Down
Binary file removed third_party/rb/vendor/cache/rubocop-0.67.2.gem
Binary file not shown.
Binary file added third_party/rb/vendor/cache/rubocop-0.72.0.gem
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.

0 comments on commit f2c647a

Please sign in to comment.