diff --git a/.rubocop-2.1.yml b/.rubocop-2.1.yml index 1152a0cb..f182c198 100644 --- a/.rubocop-2.1.yml +++ b/.rubocop-2.1.yml @@ -12,3 +12,14 @@ Layout/IndentHeredoc: Style/HashSyntax: Enabled: false + +Naming/UncommunicativeMethodParamName: + Enabled: false + +Lint/HandleExceptions: + Enabled: false + +Metrics/LineLength: + Exclude: + - 'test/resolver/native_test.rb' + Max: 140 diff --git a/.rubocop-2.3.yml b/.rubocop-2.3.yml index 7947689b..586aed12 100644 --- a/.rubocop-2.3.yml +++ b/.rubocop-2.3.yml @@ -1,7 +1,18 @@ inherit_from: .rubocop.yml +require: rubocop-performance + # TODO: remove this if min supported version of ruby is 2.3 Style/HashSyntax: Enabled: false +Naming/MethodParameterName: + Enabled: false +Lint/SuppressedException: + Enabled: false + +Layout/LineLength: + Exclude: + - 'test/resolver/native_test.rb' + Max: 140 diff --git a/.rubocop.yml b/.rubocop.yml index 8fe88c5e..613e314d 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -17,11 +17,6 @@ AllCops: - 'www/**/*' - 'lib/httpx/extensions.rb' -Metrics/LineLength: - Exclude: - - 'test/resolver/native_test.rb' - Max: 140 - Metrics/MethodLength: Max: 200 @@ -36,9 +31,6 @@ Naming/FileName: Layout/EndAlignment: EnforcedStyleAlignWith: variable -Lint/HandleExceptions: - Enabled: false - Lint/RescueException: Exclude: # starts the server in a new thread diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index 5525fb4d..e2b15642 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -40,5 +40,3 @@ Style/Documentation: Naming/AccessorMethodName: Enabled: false -Naming/UncommunicativeMethodParamName: - Enabled: false diff --git a/Gemfile b/Gemfile index 932aab84..edfc3700 100644 --- a/Gemfile +++ b/Gemfile @@ -13,7 +13,8 @@ if RUBY_VERSION < "2.2" gem "net-ssh", "~> 4.2.0", require: false gem "rb-inotify", "~> 0.9.10", require: false else - gem "rubocop", "~> 0.61.1", require: false + gem "rubocop", "~> 0.78.0", require: false + gem "rubocop-performance", "~> 1.5.2", require: false end platform :mri do diff --git a/lib/httpx/adapters/faraday.rb b/lib/httpx/adapters/faraday.rb index aac3b905..8a2e480a 100644 --- a/lib/httpx/adapters/faraday.rb +++ b/lib/httpx/adapters/faraday.rb @@ -195,16 +195,16 @@ module Faraday response_headers.merge!(response.headers) end @app.call(env) - rescue OpenSSL::SSL::SSLError => err - raise SSL_ERROR, err + rescue OpenSSL::SSL::SSLError => e + raise SSL_ERROR, e rescue Errno::ECONNABORTED, Errno::ECONNREFUSED, Errno::ECONNRESET, Errno::EHOSTUNREACH, Errno::EINVAL, Errno::ENETUNREACH, - Errno::EPIPE => err - raise CONNECTION_FAILED_ERROR, err + Errno::EPIPE => e + raise CONNECTION_FAILED_ERROR, e end private diff --git a/lib/httpx/plugins/digest_authentication.rb b/lib/httpx/plugins/digest_authentication.rb index b5b075e9..42eff469 100644 --- a/lib/httpx/plugins/digest_authentication.rb +++ b/lib/httpx/plugins/digest_authentication.rb @@ -107,7 +107,7 @@ module HTTPX if qop || sess cnonce = make_cnonce - nc = format("%08x", nc) + nc = format("%08x", nonce: nc) end a1 = if sess diff --git a/lib/httpx/plugins/proxy/socks5.rb b/lib/httpx/plugins/proxy/socks5.rb index b3ed3992..61434753 100644 --- a/lib/httpx/plugins/proxy/socks5.rb +++ b/lib/httpx/plugins/proxy/socks5.rb @@ -77,7 +77,7 @@ module HTTPX case method when PASSWD transition(:authenticating) - return + nil when NONE __on_socks5_error("no supported authorization methods") else diff --git a/lib/httpx/pool.rb b/lib/httpx/pool.rb index bf8c424a..b2435eea 100644 --- a/lib/httpx/pool.rb +++ b/lib/httpx/pool.rb @@ -33,9 +33,9 @@ module HTTPX end @timers.fire end - rescue StandardError => ex + rescue StandardError => e @connections.each do |connection| - connection.emit(:error, ex) + connection.emit(:error, e) end end diff --git a/lib/httpx/resolver/https.rb b/lib/httpx/resolver/https.rb index b5f1afd9..8c197206 100644 --- a/lib/httpx/resolver/https.rb +++ b/lib/httpx/resolver/https.rb @@ -94,11 +94,11 @@ module HTTPX def on_response(request, response) response.raise_for_status - rescue Error => ex + rescue Error => e connection = @requests[request] hostname = @queries.key(connection) - error = ResolveError.new("Can't resolve #{hostname}: #{ex.message}") - error.set_backtrace(ex.backtrace) + error = ResolveError.new("Can't resolve #{hostname}: #{e.message}") + error.set_backtrace(e.backtrace) emit(:error, connection, error) else parse(response) diff --git a/test/support/minitest_extensions.rb b/test/support/minitest_extensions.rb index da9e3bef..fefffd4d 100644 --- a/test/support/minitest_extensions.rb +++ b/test/support/minitest_extensions.rb @@ -24,7 +24,7 @@ module MinitestExtensions module FirstFailedTestInThread def self.prepended(*) super - HTTPX::Session.__send__(:include, SessionExtensions) + HTTPX::Session.include SessionExtensions end def setup diff --git a/test/test_helper.rb b/test/test_helper.rb index 39da0dbf..f54fd104 100644 --- a/test/test_helper.rb +++ b/test/test_helper.rb @@ -14,8 +14,8 @@ end require "httpx" -Dir[File.join(".", "test", "support", "*.rb")].each { |f| require f } -Dir[File.join(".", "test", "support", "**", "*.rb")].each { |f| require f } +Dir[File.join(".", "test", "support", "*.rb")].sort.each { |f| require f } +Dir[File.join(".", "test", "support", "**", "*.rb")].sort.each { |f| require f } # Ruby 2.3 openssl configuration somehow ignores SSL_CERT_FILE env var. # This adds it manually.