style: enable Style/OptionalArguments rubocop

This commit is contained in:
Gonzalo Rodriguez 2019-03-01 21:51:15 -03:00
parent 7daeac3401
commit 5a42fd3ac7
No known key found for this signature in database
GPG key ID: 5DB8B81B049B8AB1
6 changed files with 13 additions and 10 deletions

View file

@ -53,6 +53,9 @@ Style/FrozenStringLiteralComment:
Style/HashSyntax:
Enabled: true
Style/OptionalArguments:
Enabled: true
Style/RaiseArgs:
Enabled: true

View file

@ -30,7 +30,7 @@ class Rack::Attack
attr_accessor :notifier, :blocklisted_response, :throttled_response, :anonymous_blocklists, :anonymous_safelists
def safelist(name = nil, &block)
safelist = Safelist.new(name, block)
safelist = Safelist.new(name, &block)
if name
safelists[name] = safelist
@ -40,7 +40,7 @@ class Rack::Attack
end
def blocklist(name = nil, &block)
blocklist = Blocklist.new(name, block)
blocklist = Blocklist.new(name, &block)
if name
blocklists[name] = blocklist
@ -51,12 +51,12 @@ class Rack::Attack
def blocklist_ip(ip_address)
ip_blocklist_proc = lambda { |request| IPAddr.new(ip_address).include?(IPAddr.new(request.ip)) }
anonymous_blocklists << Blocklist.new(nil, ip_blocklist_proc)
anonymous_blocklists << Blocklist.new(nil, &ip_blocklist_proc)
end
def safelist_ip(ip_address)
ip_safelist_proc = lambda { |request| IPAddr.new(ip_address).include?(IPAddr.new(request.ip)) }
anonymous_safelists << Safelist.new(nil, ip_safelist_proc)
anonymous_safelists << Safelist.new(nil, &ip_safelist_proc)
end
def throttle(name, options, &block)
@ -64,7 +64,7 @@ class Rack::Attack
end
def track(name, options = {}, &block)
tracks[name] = Track.new(name, options, block)
tracks[name] = Track.new(name, options, &block)
end
def safelists;

View file

@ -3,7 +3,7 @@
module Rack
class Attack
class Blocklist < Check
def initialize(name, block)
def initialize(name, &block)
super
@type = :blocklist
end

View file

@ -4,7 +4,7 @@ module Rack
class Attack
class Check
attr_reader :name, :block, :type
def initialize(name, options = {}, block)
def initialize(name, options = {}, &block)
@name, @block = name, block
@type = options.fetch(:type, nil)
end

View file

@ -3,7 +3,7 @@
module Rack
class Attack
class Safelist < Check
def initialize(name, block)
def initialize(name, &block)
super
@type = :safelist
end

View file

@ -5,13 +5,13 @@ module Rack
class Track
attr_reader :filter
def initialize(name, options = {}, block)
def initialize(name, options = {}, &block)
options[:type] = :track
if options[:limit] && options[:period]
@filter = Throttle.new(name, options, block)
else
@filter = Check.new(name, options, block)
@filter = Check.new(name, options, &block)
end
end