Class: Reek::SnifferSet
Instance Attribute Summary collapse
-
#desc ⇒ Object
readonly
Returns the value of attribute desc.
-
#sniffers ⇒ Object
readonly
Returns the value of attribute sniffers.
Instance Method Summary collapse
-
#has_smell?(smell_class, patterns = []) ⇒ Boolean
Checks for instances of
smell_class
, and returnstrue
only if one of them has a report string matching all of thepatterns
. -
#initialize(sniffers, desc) ⇒ SnifferSet
constructor
A new instance of SnifferSet.
- #num_smells ⇒ Object
- #smells_only_of?(klass, patterns) ⇒ Boolean
- #smelly? ⇒ Boolean
- #sniff ⇒ Object
Constructor Details
#initialize(sniffers, desc) ⇒ SnifferSet
Returns a new instance of SnifferSet.
151 152 153 154 |
# File 'lib/reek/sniffer.rb', line 151 def initialize(sniffers, desc) @sniffers = sniffers @desc = desc end |
Instance Attribute Details
#desc ⇒ Object (readonly)
Returns the value of attribute desc.
149 150 151 |
# File 'lib/reek/sniffer.rb', line 149 def desc @desc end |
#sniffers ⇒ Object (readonly)
Returns the value of attribute sniffers.
149 150 151 |
# File 'lib/reek/sniffer.rb', line 149 def sniffers @sniffers end |
Instance Method Details
#has_smell?(smell_class, patterns = []) ⇒ Boolean
Checks for instances of smell_class
, and returns true
only if one of them has a report string matching all of the patterns
.
164 165 166 |
# File 'lib/reek/sniffer.rb', line 164 def has_smell?(smell_class, patterns=[]) @sniffers.any? {|sniffer| sniffer.has_smell?(smell_class, patterns)} end |
#num_smells ⇒ Object
168 169 170 171 172 |
# File 'lib/reek/sniffer.rb', line 168 def num_smells total = 0 @sniffers.each {|sniffer| total += sniffer.num_smells} total end |
#smells_only_of?(klass, patterns) ⇒ Boolean
174 175 176 |
# File 'lib/reek/sniffer.rb', line 174 def smells_only_of?(klass, patterns) num_smells == 1 and has_smell?(klass, patterns) end |
#smelly? ⇒ Boolean
156 157 158 |
# File 'lib/reek/sniffer.rb', line 156 def smelly? @sniffers.any? {|sniffer| sniffer.smelly? } end |
#sniff ⇒ Object
178 179 180 |
# File 'lib/reek/sniffer.rb', line 178 def sniff self end |