Sha256: 44a1d9f2c52ca1f04bc6a9d695fa90d5cbc99349bd530f22d9168c4a3e956889

Contents?: true

Size: 573 Bytes

Versions: 6

Compression:

Stored size: 573 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

6 entries across 6 versions & 1 rubygems

Version Path
rf-stylez-1.2.4 lib/rubocop/cop/lint/no_untyped_raise.rb
rf-stylez-1.2.3 lib/rubocop/cop/lint/no_untyped_raise.rb
rf-stylez-1.2.1 lib/rubocop/cop/lint/no_untyped_raise.rb
rf-stylez-1.1.2 lib/rubocop/cop/lint/no_untyped_raise.rb
rf-stylez-1.1.1 lib/rubocop/cop/lint/no_untyped_raise.rb
rf-stylez-1.1.0 lib/rubocop/cop/lint/no_untyped_raise.rb