diff --git a/.rubocop.yml b/.rubocop.yml index fc88c1c..28f8502 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -1,3 +1,6 @@ +require: + - rubocop-performance + inherit_mode: merge: - Exclude diff --git a/lib/rack/attack.rb b/lib/rack/attack.rb index bc54a82..f4297a5 100644 --- a/lib/rack/attack.rb +++ b/lib/rack/attack.rb @@ -67,7 +67,7 @@ module Rack end def safelists - @safelists ||= {} + @safelists ||= {} end def blocklists @@ -75,11 +75,11 @@ module Rack end def throttles - @throttles ||= {} + @throttles ||= {} end def tracks - @tracks ||= {} + @tracks ||= {} end def safelisted?(request) @@ -136,7 +136,7 @@ module Rack # Set defaults @anonymous_blocklists = [] @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"]] } @throttled_response = lambda do |env| retry_after = (env['rack.attack.match_data'] || {})[:period] diff --git a/lib/rack/attack/throttle.rb b/lib/rack/attack/throttle.rb index 071646b..c222325 100644 --- a/lib/rack/attack/throttle.rb +++ b/lib/rack/attack/throttle.rb @@ -12,7 +12,7 @@ module Rack MANDATORY_OPTIONS.each do |opt| raise ArgumentError, "Must pass #{opt.inspect} option" unless options[opt] end - @limit = options[:limit] + @limit = options[:limit] @period = options[:period].respond_to?(:call) ? options[:period] : options[:period].to_i @type = options.fetch(:type, :throttle) end diff --git a/rack-attack.gemspec b/rack-attack.gemspec index d911931..96aa458 100644 --- a/rack-attack.gemspec +++ b/rack-attack.gemspec @@ -37,7 +37,8 @@ Gem::Specification.new do |s| s.add_development_dependency "minitest-stub-const", "~> 0.6" s.add_development_dependency 'rack-test', "~> 1.0" 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" # byebug only works with MRI