Sha256: d63c54ef82e0851d9e6cd9c07a85bf544a873917bef57d5d377e11faffbe3dc8

Contents?: true

Size: 980 Bytes

Versions: 6838

Compression:

Stored size: 980 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) unless node.body
        end
      end
    end
  end
end

Version data entries

6,838 entries across 6,832 versions & 26 rubygems

Version Path
rubocop-0.59.2 lib/rubocop/cop/lint/handle_exceptions.rb
rubocop-0.59.1 lib/rubocop/cop/lint/handle_exceptions.rb
rubocop-0.59.0 lib/rubocop/cop/lint/handle_exceptions.rb
rubocop-0.58.2 lib/rubocop/cop/lint/handle_exceptions.rb
rubocop-0.58.1 lib/rubocop/cop/lint/handle_exceptions.rb
rubocop-0.58.0 lib/rubocop/cop/lint/handle_exceptions.rb
vagrant-packet-0.1.1 vendor/bundle/ruby/2.4.0/gems/rubocop-0.57.2/lib/rubocop/cop/lint/handle_exceptions.rb
rubocop-0.57.2 lib/rubocop/cop/lint/handle_exceptions.rb
rubocop-0.57.1 lib/rubocop/cop/lint/handle_exceptions.rb
rubocop-0.57.0 lib/rubocop/cop/lint/handle_exceptions.rb
rubocop-0.56.0 lib/rubocop/cop/lint/handle_exceptions.rb
rubocop-0.55.0 lib/rubocop/cop/lint/handle_exceptions.rb
rubocop-0.54.0 lib/rubocop/cop/lint/handle_exceptions.rb
rubocop-0.53.0 lib/rubocop/cop/lint/handle_exceptions.rb
rubocop-0.52.1 lib/rubocop/cop/lint/handle_exceptions.rb
rubocop-0.52.0 lib/rubocop/cop/lint/handle_exceptions.rb
rubocop-0.51.0 lib/rubocop/cop/lint/handle_exceptions.rb
rubocop-0.50.0 lib/rubocop/cop/lint/handle_exceptions.rb