Class: Reek::Smells::PrimaDonnaMethod Private

Inherits:
SmellDetector show all
Defined in:
lib/reek/smells/prima_donna_method.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.

Excerpt from: dablog.rubypal.com/2007/8/15/bang-methods-or-danger-will-rubyist since this sums it up really well:

The ! in method names that end with ! means, "This method is dangerous"
-- or, more precisely, this method is the "dangerous" version of an
equivalent method, with the same name minus the !. "Danger" is
relative; the ! doesn't mean anything at all unless the method name
it's in corresponds to a similar but bang-less method name.

Don't add ! to your destructive (receiver-changing) methods' names,
unless you consider the changing to be "dangerous" and you have a
"non-dangerous" equivalent method without the !. If some arbitrary
subset of destructive methods end with !, then the whole point of !
gets distorted and diluted, and ! ceases to convey any information
whatsoever.

Such a method is called PrimaDonnaMethod and is reported as a smell.

See Prima-Donna-Method for details.

Constant Summary

Constants inherited from SmellDetector

SmellDetector::DEFAULT_EXCLUDE_SET, SmellDetector::EXCLUDE_KEY

Instance Attribute Summary

Attributes inherited from SmellDetector

#smells_found, #source

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from SmellDetector

#config_for, #configure_with, default_config, default_smell_category, descendants, #enabled?, #enabled_for?, #examine, #exception?, #initialize, #register, #report_on, smell_category, #smell_category, smell_type, #smell_type, #value

Constructor Details

This class inherits a constructor from Reek::Smells::SmellDetector

Class Method Details

.contextsObject

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.

:nodoc:



28
29
30
# File 'lib/reek/smells/prima_donna_method.rb', line 28

def self.contexts # :nodoc:
  [:class]
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.



32
33
34
35
36
# File 'lib/reek/smells/prima_donna_method.rb', line 32

def examine_context(ctx)
  ctx.node_instance_methods.map do |method_sexp|
    check_for_smells(method_sexp, ctx)
  end.compact
end