From 20d668211e9bd64d918e987b6053462e4bdb570e Mon Sep 17 00:00:00 2001 From: Gonzalo Rodriguez Date: Thu, 28 Feb 2019 21:17:36 -0300 Subject: [PATCH] style: fix Lint/HandleExceptions rubocop --- .rubocop.yml | 5 ----- lib/rack/attack/store_proxy/dalli_proxy.rb | 4 ++++ lib/rack/attack/store_proxy/redis_proxy.rb | 4 ++++ lib/rack/attack/store_proxy/redis_store_proxy.rb | 2 ++ spec/spec_helper.rb | 1 + 5 files changed, 11 insertions(+), 5 deletions(-) diff --git a/.rubocop.yml b/.rubocop.yml index 2ced30d..f21b1b1 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -49,8 +49,3 @@ Style/HashSyntax: Style/RedundantFreeze: Enabled: true - -# TODO -# Remove cop disabling and fix offenses -Lint/HandleExceptions: - Enabled: false diff --git a/lib/rack/attack/store_proxy/dalli_proxy.rb b/lib/rack/attack/store_proxy/dalli_proxy.rb index f3fbc6c..0b6cfb0 100644 --- a/lib/rack/attack/store_proxy/dalli_proxy.rb +++ b/lib/rack/attack/store_proxy/dalli_proxy.rb @@ -28,6 +28,7 @@ module Rack client.get(key) end rescue Dalli::DalliError + nil end def write(key, value, options = {}) @@ -35,6 +36,7 @@ module Rack client.set(key, value, options.fetch(:expires_in, 0), raw: true) end rescue Dalli::DalliError + nil end def increment(key, amount, options = {}) @@ -42,6 +44,7 @@ module Rack client.incr(key, amount, options.fetch(:expires_in, 0), amount) end rescue Dalli::DalliError + nil end def delete(key) @@ -49,6 +52,7 @@ module Rack client.delete(key) end rescue Dalli::DalliError + nil end private diff --git a/lib/rack/attack/store_proxy/redis_proxy.rb b/lib/rack/attack/store_proxy/redis_proxy.rb index 69fa19d..5572d0c 100644 --- a/lib/rack/attack/store_proxy/redis_proxy.rb +++ b/lib/rack/attack/store_proxy/redis_proxy.rb @@ -21,6 +21,7 @@ module Rack def read(key) get(key) rescue Redis::BaseError + nil end def write(key, value, options = {}) @@ -30,6 +31,7 @@ module Rack set(key, value) end rescue Redis::BaseError + nil end def increment(key, amount, options = {}) @@ -42,11 +44,13 @@ module Rack count.value if count rescue Redis::BaseError + nil end def delete(key, _options = {}) del(key) rescue Redis::BaseError + nil end end end diff --git a/lib/rack/attack/store_proxy/redis_store_proxy.rb b/lib/rack/attack/store_proxy/redis_store_proxy.rb index 359b542..d7b753c 100644 --- a/lib/rack/attack/store_proxy/redis_store_proxy.rb +++ b/lib/rack/attack/store_proxy/redis_store_proxy.rb @@ -13,6 +13,7 @@ module Rack def read(key) get(key, raw: true) rescue Redis::BaseError + nil end def write(key, value, options = {}) @@ -22,6 +23,7 @@ module Rack set(key, value, raw: true) end rescue Redis::BaseError + nil end end end diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index b46161e..ad377bf 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -18,6 +18,7 @@ def safe_require(name) begin require name rescue LoadError + nil end end