Class: Reek::Smells::NilCheck Private
- Inherits:
-
SmellDetector
- Object
- SmellDetector
- Reek::Smells::NilCheck
- Defined in:
- lib/reek/smells/nil_check.rb
Overview
This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.
Checking for nil is a special kind of type check, and therefore a case of SimulatedPolymorphism.
See Nil-Check for details.
Defined Under Namespace
Modules: NilCallNodeDetector, NilWhenNodeDetector Classes: NodeFinder
Constant Summary
Constants inherited from SmellDetector
SmellDetector::DEFAULT_EXCLUDE_SET, SmellDetector::EXCLUDE_KEY
Instance Attribute Summary
Attributes inherited from SmellDetector
Class Method Summary collapse
- .smell_category ⇒ Object private
Instance Method Summary collapse
- #examine_context(ctx) ⇒ Object private
Methods inherited from SmellDetector
#config_for, #configure_with, contexts, default_config, default_smell_category, descendants, #enabled?, #enabled_for?, #examine, #exception?, #initialize, #register, #report_on, #smell_category, smell_type, #smell_type, #value
Constructor Details
This class inherits a constructor from Reek::Smells::SmellDetector
Class Method Details
.smell_category ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
12 13 14 |
# File 'lib/reek/smells/nil_check.rb', line 12 def self.smell_category 'SimulatedPolymorphism' end |
Instance Method Details
#examine_context(ctx) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/reek/smells/nil_check.rb', line 16 def examine_context(ctx) call_node_finder = NodeFinder.new(ctx, :send, NilCallNodeDetector) case_node_finder = NodeFinder.new(ctx, :when, NilWhenNodeDetector) smelly_nodes = call_node_finder.smelly_nodes + case_node_finder.smelly_nodes smelly_nodes.map do |node| SmellWarning.new self, context: ctx.full_name, lines: [node.line], message: 'performs a nil-check' end end |