From 53c1d93fd1619425553e4436c428959c3049b1e2 Mon Sep 17 00:00:00 2001 From: Gonzalo Rodriguez Date: Sat, 25 Apr 2020 15:42:30 -0300 Subject: [PATCH] style: avoid multiline ternary operator --- .rubocop.yml | 6 ++++++ lib/rack/attack.rb | 14 ++++++++++---- 2 files changed, 16 insertions(+), 4 deletions(-) diff --git a/.rubocop.yml b/.rubocop.yml index b12c0b4..2aebea2 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -68,6 +68,12 @@ Style/FrozenStringLiteralComment: Style/HashSyntax: Enabled: true +Style/MultilineTernaryOperator: + Enabled: true + +Style/NestedTernaryOperator: + Enabled: true + Style/OptionalArguments: Enabled: true diff --git a/lib/rack/attack.rb b/lib/rack/attack.rb index d29bf68..47ba82f 100644 --- a/lib/rack/attack.rb +++ b/lib/rack/attack.rb @@ -110,12 +110,18 @@ module Rack @app.call(env) elsif configuration.blocklisted?(request) # Deprecated: Keeping blocklisted_response for backwards compatibility - configuration.blocklisted_response ? configuration.blocklisted_response.call(env) : - configuration.blocklisted_callback.call(request) + if configuration.blocklisted_response + configuration.blocklisted_response.call(env) + else + configuration.blocklisted_callback.call(request) + end elsif configuration.throttled?(request) # Deprecated: Keeping throttled_response for backwards compatibility - configuration.throttled_response ? configuration.throttled_response.call(env) : - configuration.throttled_callback.call(request) + if configuration.throttled_response + configuration.throttled_response.call(env) + else + configuration.throttled_callback.call(request) + end else configuration.tracked?(request) @app.call(env)