added separate configs per ruby version, which helps keeping up the level of granularity way better than just having a single rubocop_todo.yml; fixed a few cases based on some missing cops

This commit is contained in:
HoneyryderChuck 2018-12-28 14:02:28 +00:00
parent 7673f572c2
commit 0668ff6d92
15 changed files with 55 additions and 36 deletions

14
.rubocop-2.1.yml Normal file
View File

@ -0,0 +1,14 @@
inherit_from: .rubocop.yml
# Because this cop doesn't work well with frozen regexes
Style/RedundantFreeze:
Enabled: false
Style/FrozenStringLiteralComment:
Enabled: false
Layout/IndentHeredoc:
Enabled: false
Style/HashSyntax:
Enabled: false

5
.rubocop-2.2.yml Normal file
View File

@ -0,0 +1,5 @@
inherit_from: .rubocop-2.1.yml
# Because this cop doesn't work well with frozen regexes
Style/RedundantFreeze:
Enabled: false

7
.rubocop-2.3.yml Normal file
View File

@ -0,0 +1,7 @@
inherit_from: .rubocop.yml
# TODO: remove this if min supported version of ruby is 2.3
Style/HashSyntax:
Enabled: false

1
.rubocop-2.4.yml Normal file
View File

@ -0,0 +1 @@
inherit_from: .rubocop-2.3.yml

1
.rubocop-2.5.yml Normal file
View File

@ -0,0 +1 @@
inherit_from: .rubocop-2.3.yml

1
.rubocop-2.6.yml Normal file
View File

@ -0,0 +1 @@
inherit_from: .rubocop-2.3.yml

View File

@ -71,12 +71,6 @@ Style/StringLiteralsInInterpolation:
Style/GlobalVars:
AllowedVariables: [$PALANCA_DEBUG]
#Style/SpaceAroundOperators:
# Enabled: false
#Style/ExtraSpacing:
# Enabled: false
Style/ClassVars:
Exclude:
# header field transformation caches
@ -86,9 +80,6 @@ Style/ClassVars:
Style/SignalException:
Enabled: false
Style/FrozenStringLiteralComment:
Enabled: false
Style/ParallelAssignment:
Enabled: false

View File

@ -21,10 +21,6 @@ Metrics/BlockNesting:
#Naming/MethodName:
# TODO: remove this if min supported version of ruby is 2.3
Layout/IndentHeredoc:
Enabled: false
Style/SafeNavigation:
Enabled: false
@ -34,10 +30,6 @@ Security/Eval:
Style/ClassAndModuleChildren:
Enabled: false
# TODO: remove this if min supported version of ruby is 2.3
Style/HashSyntax:
Enabled: false
Style/NumericPredicate:
Exclude:
- lib/palanca/extensions/*.rb

View File

@ -10,7 +10,7 @@ gem "rake", "~> 12.3"
gem "simplecov", require: false
if RUBY_VERSION < "2.2"
gem "rubocop", "~> 0.57.2", require: false
gem "rubocop", "~> 0.57.0", require: false
else
gem "rubocop", "~> 0.61.1", require: false
end

View File

@ -11,9 +11,11 @@ Rake::TestTask.new do |t|
t.warning = false
end
RUBY_MAJOR_MINOR = RUBY_VERSION.split(/\./).first(2).join(".")
desc "Run rubocop"
task :rubocop do
RuboCop::RakeTask.new
RuboCop::RakeTask.new(:rubocop) do |task|
task.options += %W[-c.rubocop-#{RUBY_MAJOR_MINOR}.yml]
end
task :"test:ci" => %i[test rubocop]

View File

@ -34,6 +34,7 @@ module HTTPX
requests = __build_reqs(*args, **options)
responses = __send_reqs(*requests, **options)
return responses.first if responses.size == 1
responses
ensure
close unless keep_open

View File

@ -114,14 +114,14 @@ module HTTPX
end
def parse(response)
answers = begin
decode_response_body(response)
rescue Resolv::DNS::DecodeError, JSON::JSONError => e
host, channel = @queries.first
if @_record_types[host].empty?
emit_resolve_error(channel, host, e)
return
end
begin
answers = decode_response_body(response)
rescue Resolv::DNS::DecodeError, JSON::JSONError => e
host, channel = @queries.first
if @_record_types[host].empty?
emit_resolve_error(channel, host, e)
return
end
end
if answers.empty?
host, channel = @queries.first

View File

@ -182,14 +182,14 @@ module HTTPX
end
def parse(buffer)
addresses = begin
Resolver.decode_dns_answer(buffer)
rescue Resolv::DNS::DecodeError => e
hostname, channel = @queries.first
if @_record_types[hostname].empty?
emit_resolve_error(channel, hostname, e)
return
end
begin
addresses = Resolver.decode_dns_answer(buffer)
rescue Resolv::DNS::DecodeError => e
hostname, channel = @queries.first
if @_record_types[hostname].empty?
emit_resolve_error(channel, hostname, e)
return
end
end
if addresses.empty?

View File

@ -1,3 +1,5 @@
# frozen_string_literal: true
module ProxyRetry
def run(*)
return super unless name.include?("_proxy")

View File

@ -1,3 +1,5 @@
# frozen_string_literal: true
module Requests
module Errors
def test_errors_connection_refused