Class: Reek::SnifferSet

Inherits:
Object show all
Defined in:
lib/reek/sniffer.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#descObject (readonly)

Returns the value of attribute desc.



149
150
151
# File 'lib/reek/sniffer.rb', line 149

def desc
  @desc
end

#sniffersObject (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.

Returns:

  • (Boolean)


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_smellsObject



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

Returns:

  • (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

Returns:

  • (Boolean)


156
157
158
# File 'lib/reek/sniffer.rb', line 156

def smelly?
  @sniffers.any? {|sniffer| sniffer.smelly? }
end

#sniffObject



178
179
180
# File 'lib/reek/sniffer.rb', line 178

def sniff
  self
end