Sha256: cf2f0d1681283c874274e97224315022d907fdedf03b15fad78501e31fe88f47

Contents?: true

Size: 993 Bytes

Versions: 4

Compression:

Stored size: 993 Bytes

Contents

# frozen_string_literal: true

module RuboCop
  module Cop
    module Lint
      # This cop checks for *rescue* blocks with no body.
      #
      # @example
      #
      #   # bad
      #
      #   def some_method
      #     do_something
      #   rescue
      #     # do nothing
      #   end
      #
      # @example
      #
      #   # bad
      #
      #   begin
      #     do_something
      #   rescue
      #     # do nothing
      #   end
      #
      # @example
      #
      #   # good
      #
      #   def some_method
      #     do_something
      #   rescue
      #     handle_exception
      #   end
      #
      # @example
      #
      #   # good
      #
      #   begin
      #     do_something
      #   rescue
      #     handle_exception
      #   end
      class HandleExceptions < Cop
        MSG = 'Do not suppress exceptions.'.freeze

        def on_resbody(node)
          add_offense(node, :expression) unless node.body
        end
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
rubocop-0.49.1 lib/rubocop/cop/lint/handle_exceptions.rb
rubocop-0.49.0 lib/rubocop/cop/lint/handle_exceptions.rb
rubocop-0.48.1 lib/rubocop/cop/lint/handle_exceptions.rb
rubocop-0.48.0 lib/rubocop/cop/lint/handle_exceptions.rb