From 32297d027cbf65c3db8ee77299abe6f550ba2dc6 Mon Sep 17 00:00:00 2001 From: Thomas Walpole Date: Mon, 29 Apr 2019 11:11:01 -0700 Subject: [PATCH] Update to rubocop 0.68 --- .rubocop.yml | 9 +++++++-- lib/capybara/node/actions.rb | 4 ++-- lib/capybara/node/element.rb | 4 +--- lib/capybara/queries/selector_query.rb | 2 +- lib/capybara/rack_test/node.rb | 2 +- lib/capybara/rspec/matchers/base.rb | 4 ++-- lib/capybara/selenium/driver.rb | 6 +++--- .../selenium/driver_specializations/chrome_driver.rb | 4 ++-- lib/capybara/server/checker.rb | 2 +- lib/capybara/window.rb | 2 +- 10 files changed, 21 insertions(+), 18 deletions(-) diff --git a/.rubocop.yml b/.rubocop.yml index 0abf2c72..709b7eb1 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -19,7 +19,7 @@ Metrics/LineLength: - 'lib/capybara/spec/**/*' - 'lib/capybara/selector.rb' IgnoredPatterns: - - '\s+# rubocop' + - '\s+# _?rubocop' - '^\s*#' - '^\s*(raise|warn) ' Max: 120 @@ -63,6 +63,11 @@ Lint/UnusedMethodArgument: Layout/EndAlignment: EnforcedStyleAlignWith: variable + +Naming/RescuedExceptionsVariableName: + # This cop is currently fully broken + Enabled: false + Naming/PredicateName: Exclude: - '**/*/*matchers.rb' @@ -121,7 +126,7 @@ Layout/AccessModifierIndentation: Layout/CaseIndentation: EnforcedStyle: end -Layout/IndentArray: +Layout/IndentFirstArrayElement: EnforcedStyle: consistent Security/YAMLLoad: diff --git a/lib/capybara/node/actions.rb b/lib/capybara/node/actions.rb index a2d56dac..c50168f1 100644 --- a/lib/capybara/node/actions.rb +++ b/lib/capybara/node/actions.rb @@ -300,12 +300,12 @@ module Capybara synchronize(Capybara::Queries::BaseQuery.wait(options, session_options.default_max_wait_time)) do begin find(:select, from, options) - rescue Capybara::ElementNotFound => select_error # rubocop:disable Naming/RescuedExceptionsVariableName + rescue Capybara::ElementNotFound => select_error # _rubocop:disable Naming/RescuedExceptionsVariableName raise if %i[selected with_selected multiple].any? { |option| options.key?(option) } begin find(:datalist_input, from, options) - rescue Capybara::ElementNotFound => dlinput_error + rescue Capybara::ElementNotFound => dlinput_error # _rubocop:disable Naming/RescuedExceptionsVariableName raise Capybara::ElementNotFound, "#{select_error.message} and #{dlinput_error.message}" end end diff --git a/lib/capybara/node/element.rb b/lib/capybara/node/element.rb index 308ad1b5..bee19ea2 100644 --- a/lib/capybara/node/element.rb +++ b/lib/capybara/node/element.rb @@ -480,9 +480,7 @@ module Capybara %(#) rescue NotSupportedByDriverError %(#) - rescue StandardError => err - raise unless session.driver.invalid_element_errors.any? { |et| err.is_a?(et) } - + rescue *session.driver.invalid_element_errors %(Obsolete #) end diff --git a/lib/capybara/queries/selector_query.rb b/lib/capybara/queries/selector_query.rb index b95a331a..755e0fcd 100644 --- a/lib/capybara/queries/selector_query.rb +++ b/lib/capybara/queries/selector_query.rb @@ -88,7 +88,7 @@ module Capybara matches_system_filters?(node) && matches_node_filters?(node, node_filter_errors) && matches_filter_block?(node) - rescue *(node.respond_to?(:session) ? node.session.driver.invalid_element_errors : []) # rubocop:disable Naming/RescuedExceptionsVariableName + rescue *(node.respond_to?(:session) ? node.session.driver.invalid_element_errors : []) # _rubocop:disable Naming/RescuedExceptionsVariableName false end diff --git a/lib/capybara/rack_test/node.rb b/lib/capybara/rack_test/node.rb index 24c56cab..f44eb643 100644 --- a/lib/capybara/rack_test/node.rb +++ b/lib/capybara/rack_test/node.rb @@ -118,7 +118,7 @@ class Capybara::RackTest::Node < Capybara::Driver::Node public_instance_methods(false).each do |meth_name| alias_method "unchecked_#{meth_name}", meth_name - private "unchecked_#{meth_name}" # rubocop:disable Layout/AccessModifierIndentation,Style/AccessModifierDeclarations + private "unchecked_#{meth_name}" # rubocop:disable Style/AccessModifierDeclarations define_method meth_name do |*args| stale_check diff --git a/lib/capybara/rspec/matchers/base.rb b/lib/capybara/rspec/matchers/base.rb index 742139c3..a0ea61b0 100644 --- a/lib/capybara/rspec/matchers/base.rb +++ b/lib/capybara/rspec/matchers/base.rb @@ -48,8 +48,8 @@ module Capybara def does_not_match?(actual) element_does_not_match?(wrap(actual)) - rescue Capybara::ExpectationNotMet => err - @failure_message_when_negated = err.message + rescue Capybara::ExpectationNotMet => e + @failure_message_when_negated = e.message false end diff --git a/lib/capybara/selenium/driver.rb b/lib/capybara/selenium/driver.rb index a6510e4a..70d38768 100644 --- a/lib/capybara/selenium/driver.rb +++ b/lib/capybara/selenium/driver.rb @@ -226,10 +226,10 @@ class Capybara::Selenium::Driver < Capybara::Driver::Base @browser&.quit rescue Selenium::WebDriver::Error::SessionNotCreatedError, Errno::ECONNREFUSED # rubocop:disable Lint/HandleExceptions # Browser must have already gone - rescue Selenium::WebDriver::Error::UnknownError => err - unless silenced_unknown_error_message?(err.message) # Most likely already gone + rescue Selenium::WebDriver::Error::UnknownError => e + unless silenced_unknown_error_message?(e.message) # Most likely already gone # probably already gone but not sure - so warn - warn "Ignoring Selenium UnknownError during driver quit: #{err.message}" + warn "Ignoring Selenium UnknownError during driver quit: #{e.message}" end ensure @browser = nil diff --git a/lib/capybara/selenium/driver_specializations/chrome_driver.rb b/lib/capybara/selenium/driver_specializations/chrome_driver.rb index d0965c1f..8131b46b 100644 --- a/lib/capybara/selenium/driver_specializations/chrome_driver.rb +++ b/lib/capybara/selenium/driver_specializations/chrome_driver.rb @@ -18,8 +18,8 @@ module Capybara::Selenium::Driver::ChromeDriver def resize_window_to(handle, width, height) super - rescue Selenium::WebDriver::Error::UnknownError => err - raise unless err.message.match?(/failed to change window state/) + rescue Selenium::WebDriver::Error::UnknownError => e + raise unless e.message.match?(/failed to change window state/) # Chromedriver doesn't wait long enough for state to change when coming out of fullscreen # and raises unnecessary error. Wait a bit and try again. diff --git a/lib/capybara/server/checker.rb b/lib/capybara/server/checker.rb index 089bedcf..fccea773 100644 --- a/lib/capybara/server/checker.rb +++ b/lib/capybara/server/checker.rb @@ -12,7 +12,7 @@ module Capybara def request(&block) ssl? ? https_request(&block) : http_request(&block) - rescue *TRY_HTTPS_ERRORS # rubocop:disable Naming/RescuedExceptionsVariableName + rescue *TRY_HTTPS_ERRORS # _rubocop:disable Naming/RescuedExceptionsVariableName res = https_request(&block) @ssl = true res diff --git a/lib/capybara/window.rb b/lib/capybara/window.rb index 89107a85..71215e65 100644 --- a/lib/capybara/window.rb +++ b/lib/capybara/window.rb @@ -49,7 +49,7 @@ module Capybara # @return [Boolean] whether this window is the window in which commands are being executed def current? @driver.current_window_handle == @handle - rescue @driver.no_such_window_error # rubocop:disable Naming/RescuedExceptionsVariableName + rescue @driver.no_such_window_error # _rubocop:disable Naming/RescuedExceptionsVariableName false end