style: update to latest rubocop

This commit is contained in:
Gonzalo Rodriguez 2019-08-02 17:04:52 -03:00
parent 8fafa7602b
commit 0ce6befd68
No known key found for this signature in database
GPG key ID: 5DB8B81B049B8AB1
4 changed files with 10 additions and 6 deletions

View file

@ -1,3 +1,6 @@
require:
- rubocop-performance
inherit_mode: inherit_mode:
merge: merge:
- Exclude - Exclude

View file

@ -67,7 +67,7 @@ module Rack
end end
def safelists def safelists
@safelists ||= {} @safelists ||= {}
end end
def blocklists def blocklists
@ -75,11 +75,11 @@ module Rack
end end
def throttles def throttles
@throttles ||= {} @throttles ||= {}
end end
def tracks def tracks
@tracks ||= {} @tracks ||= {}
end end
def safelisted?(request) def safelisted?(request)
@ -136,7 +136,7 @@ module Rack
# Set defaults # Set defaults
@anonymous_blocklists = [] @anonymous_blocklists = []
@anonymous_safelists = [] @anonymous_safelists = []
@notifier = ActiveSupport::Notifications if defined?(ActiveSupport::Notifications) @notifier = ActiveSupport::Notifications if defined?(ActiveSupport::Notifications)
@blocklisted_response = lambda { |_env| [403, { 'Content-Type' => 'text/plain' }, ["Forbidden\n"]] } @blocklisted_response = lambda { |_env| [403, { 'Content-Type' => 'text/plain' }, ["Forbidden\n"]] }
@throttled_response = lambda do |env| @throttled_response = lambda do |env|
retry_after = (env['rack.attack.match_data'] || {})[:period] retry_after = (env['rack.attack.match_data'] || {})[:period]

View file

@ -12,7 +12,7 @@ module Rack
MANDATORY_OPTIONS.each do |opt| MANDATORY_OPTIONS.each do |opt|
raise ArgumentError, "Must pass #{opt.inspect} option" unless options[opt] raise ArgumentError, "Must pass #{opt.inspect} option" unless options[opt]
end end
@limit = options[:limit] @limit = options[:limit]
@period = options[:period].respond_to?(:call) ? options[:period] : options[:period].to_i @period = options[:period].respond_to?(:call) ? options[:period] : options[:period].to_i
@type = options.fetch(:type, :throttle) @type = options.fetch(:type, :throttle)
end end

View file

@ -37,7 +37,8 @@ Gem::Specification.new do |s|
s.add_development_dependency "minitest-stub-const", "~> 0.6" s.add_development_dependency "minitest-stub-const", "~> 0.6"
s.add_development_dependency 'rack-test', "~> 1.0" s.add_development_dependency 'rack-test', "~> 1.0"
s.add_development_dependency 'rake', "~> 12.3" s.add_development_dependency 'rake', "~> 12.3"
s.add_development_dependency "rubocop", "0.67.2" s.add_development_dependency "rubocop", "0.74.0"
s.add_development_dependency "rubocop-performance", "~> 1.4.1"
s.add_development_dependency "timecop", "~> 0.9.1" s.add_development_dependency "timecop", "~> 0.9.1"
# byebug only works with MRI # byebug only works with MRI