Class: Simplabs::Excellent::Checks::EmptyRescueBodyCheck

Inherits:
Base
  • Object
show all
Defined in:
lib/simplabs/excellent/checks/empty_rescue_body_check.rb

Overview

This check reports empty rescue blocks. Empty rescue blocks suppress all errors which is usually not a good technique.

Applies to

  • rescue blocks

Instance Attribute Summary

Attributes inherited from Base

#interesting_files, #interesting_nodes, #warnings

Instance Method Summary collapse

Methods inherited from Base

#add_warning, #evaluate_node, #warnings_for

Constructor Details

#initializeEmptyRescueBodyCheck

:nodoc:



16
17
18
19
# File 'lib/simplabs/excellent/checks/empty_rescue_body_check.rb', line 16

def initialize #:nodoc:
  super
  @interesting_nodes = [:resbody]
end

Instance Method Details

#evaluate(context) ⇒ Object

:nodoc:



21
22
23
# File 'lib/simplabs/excellent/checks/empty_rescue_body_check.rb', line 21

def evaluate(context) #:nodoc:
  add_warning(context, 'Rescue block is empty.', {}, -1) unless context.has_statements?
end