Class: RuboCop::Cop::Workit::NoopRescue

Inherits:
Base
  • Object
show all
Defined in:
lib/rubocop/cop/workit/noop_rescue.rb

Overview

Check for suppress or ignore checked exception.

Examples:

# bad
foo rescue nil

# bad
def foo
  do_something
rescue StandardError => e
  # no op
end

# good
foo rescue do_something

# good
def foo
  do_something
rescue StandardError => e
  do_something
end

Constant Summary collapse

MSG =
"Don't suppress or ignore checked exception."

Instance Method Summary collapse

Instance Method Details

#on_resbody(node) ⇒ Object



37
38
39
# File 'lib/rubocop/cop/workit/noop_rescue.rb', line 37

def on_resbody(node)
  add_offense(node) if noop?(node.body)
end

#send_node_include?(node) ⇒ Object



33
34
35
# File 'lib/rubocop/cop/workit/noop_rescue.rb', line 33

def_node_search :send_node_include?, <<~PATTERN
  (send ...)
PATTERN