Sha256: e5c294ec3f65556902f2a5e353eab1952a442df516fe02880a57cd567d8f2ace

Contents?: true

Size: 572 Bytes

Versions: 29

Compression:

Stored size: 572 Bytes

Contents

# frozen_string_literal: true

module RuboCop
  module Cop
    module Lint
      # @example
      #   # bad
      #   raise 'foo'
      #
      #   # good
      #   raise ArgumentError, 'foo'
      #
      class NoUntypedRaise < Cop
        MSG = 'Do not raise untyped exceptions, specify the error type so it can be rescued specifically.'

        def_node_matcher :is_untyped_raise?, '(send nil? {:raise :fail} (str ...) ...)'

        def on_send(node)
          return unless is_untyped_raise?(node)
          add_offense(node)
        end
      end
    end
  end
end

Version data entries

29 entries across 29 versions & 1 rubygems

Version Path
rf-stylez-1.0.1 lib/rubocop/cop/lint/no_untyped_raise.rb
rf-stylez-1.0.0 lib/rubocop/cop/lint/no_untyped_raise.rb
rf-stylez-0.16.0 lib/rubocop/cop/lint/no_untyped_raise.rb
rf-stylez-0.15.0 lib/rubocop/cop/lint/no_untyped_raise.rb
rf-stylez-0.14.0 lib/rubocop/cop/lint/no_untyped_raise.rb
rf-stylez-0.13.0 lib/rubocop/cop/lint/no_untyped_raise.rb
rf-stylez-0.12.0 lib/rubocop/cop/lint/no_untyped_raise.rb
rf-stylez-0.11.1 lib/rubocop/cop/lint/no_untyped_raise.rb
rf-stylez-0.11.0 lib/rubocop/cop/lint/no_untyped_raise.rb
rf-stylez-0.10.0 lib/rubocop/cop/lint/no_untyped_raise.rb
rf-stylez-0.9.0 lib/rubocop/cop/lint/no_untyped_raise.rb
rf-stylez-0.8.0 lib/rubocop/cop/lint/no_untyped_raise.rb
rf-stylez-0.8.0.pre2 lib/rubocop/cop/lint/no_untyped_raise.rb
rf-stylez-0.8.0.pre lib/rubocop/cop/lint/no_untyped_raise.rb
rf-stylez-0.7.2 lib/rubocop/cop/lint/no_untyped_raise.rb
rf-stylez-0.7.2.pre2 lib/rubocop/cop/lint/no_untyped_raise.rb
rf-stylez-0.7.2.pre lib/rubocop/cop/lint/no_untyped_raise.rb
rf-stylez-0.7.1 lib/rubocop/cop/lint/no_untyped_raise.rb
rf-stylez-0.7.1.pre lib/rubocop/cop/lint/no_untyped_raise.rb
rf-stylez-0.7.0 lib/rubocop/cop/lint/no_untyped_raise.rb