Class: Reek::DetectorStack
Instance Method Summary collapse
- #has_smell?(patterns) ⇒ Boolean
-
#initialize(default_detector) ⇒ DetectorStack
constructor
A new instance of DetectorStack.
- #listen_to(hooks) ⇒ Object
- #num_smells ⇒ Object
- #push(config) ⇒ Object
- #report_on(report) ⇒ Object
- #smelly? ⇒ Boolean
Constructor Details
#initialize(default_detector) ⇒ DetectorStack
Returns a new instance of DetectorStack.
5 6 7 |
# File 'lib/reek/detector_stack.rb', line 5 def initialize(default_detector) @detectors = [default_detector] end |
Instance Method Details
#has_smell?(patterns) ⇒ Boolean
28 29 30 31 |
# File 'lib/reek/detector_stack.rb', line 28 def has_smell?(patterns) @detectors.each { |det| return true if det.has_smell?(patterns) } false end |
#listen_to(hooks) ⇒ Object
14 15 16 |
# File 'lib/reek/detector_stack.rb', line 14 def listen_to(hooks) @detectors.each { |det| det.listen_to(hooks) } end |
#num_smells ⇒ Object
22 23 24 25 26 |
# File 'lib/reek/detector_stack.rb', line 22 def num_smells total = 0 @detectors.each { |det| total += det.num_smells } total end |
#push(config) ⇒ Object
9 10 11 12 |
# File 'lib/reek/detector_stack.rb', line 9 def push(config) clone = @detectors[-1].supersede_with(config) @detectors << clone end |
#report_on(report) ⇒ Object
18 19 20 |
# File 'lib/reek/detector_stack.rb', line 18 def report_on(report) @detectors.each { |det| det.report_on(report) } end |
#smelly? ⇒ Boolean
33 34 35 36 37 |
# File 'lib/reek/detector_stack.rb', line 33 def smelly? # SMELL: Duplication: look at al those loops! @detectors.each { |det| return true if det.smelly? } false end |