diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index 99f085e..9224e63 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -122,14 +122,6 @@ Style/Documentation: - 'lib/webhook_system/encoder.rb' - 'lib/webhook_system/subscription_topic.rb' -# Offense count: 2 -# This cop supports safe autocorrection (--autocorrect). -# Configuration parameters: MinBodyLength, AllowConsecutiveConditionals. -Style/GuardClause: - Exclude: - - 'lib/webhook_system/base_event.rb' - - 'lib/webhook_system/job.rb' - # Offense count: 19 # This cop supports safe autocorrection (--autocorrect). # Configuration parameters: EnforcedStyle, EnforcedShorthandSyntax, UseHashRocketsWithSymbolValues, PreferHashRocketsForNonAlnumEndingSymbols. diff --git a/lib/webhook_system/base_event.rb b/lib/webhook_system/base_event.rb index 19482d0..f8cce27 100644 --- a/lib/webhook_system/base_event.rb +++ b/lib/webhook_system/base_event.rb @@ -57,10 +57,11 @@ def with_caller_backtrace(exception, backtrack = 2) end def validate_attribute_name(key) - if self.class.key_is_reserved?(key) - message = "#{self.class.name} should not be defining an attribute named #{key} since its reserved" - raise ArgumentError, message - end + return unless self.class.key_is_reserved?(key) + + message = "#{self.class.name} should not be defining an attribute named #{key} since its reserved" + raise ArgumentError, message + end def each_attribute(&block) diff --git a/lib/webhook_system/job.rb b/lib/webhook_system/job.rb index 5d0e366..48440b2 100644 --- a/lib/webhook_system/job.rb +++ b/lib/webhook_system/job.rb @@ -70,16 +70,17 @@ def self.post(subscription, event) def self.ensure_success(response, http_method, subscription) url = subscription.url status = response.status - unless (200..299).cover? status - if subscription.respond_to?(:account_id) - account_info = subscription.account_info - inner = "failed for account #{account_info} with" - else - inner = "failed with" - end - text = "#{http_method} request to #{url} #{inner} code: #{status} and error #{response.body}" - raise RequestFailed.new(text, status, response.body) + return if (200..299).cover? status + + if subscription.respond_to?(:account_id) + account_info = subscription.account_info + inner = "failed for account #{account_info} with" + else + inner = "failed with" end + text = "#{http_method} request to #{url} #{inner} code: #{status} and error #{response.body}" + raise RequestFailed.new(text, status, response.body) + end def self.build_request(client, subscription, event)