Sha256: fc2ec95483987d927daa8cdf1e8686e1303a30f8c34bbe02ad97a1249033fb56

Contents?: true

Size: 790 Bytes

Versions: 3

Compression:

Stored size: 790 Bytes

Contents

module Reek
  class DetectorStack

    def initialize(default_detector)
      @detectors = [default_detector]
    end

    def push(config)
      clone = @detectors[-1].supersede_with(config)
      @detectors << clone
    end

    def listen_to(hooks)
      @detectors.each { |det| det.listen_to(hooks) }
    end

    def report_on(report)
      @detectors.each { |det| det.report_on(report) }
    end

    def num_smells
      @detectors.inject(0) { |total, detector| total += detector.num_smells }
    end

    def has_smell?(patterns)
      @detectors.each { |det| return true if det.has_smell?(patterns) }
      false
    end

    def smelly?
      # SMELL: Duplication: look at all those loops!
      @detectors.each { |det| return true if det.smelly? }
      false
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
reek-1.2.6 lib/reek/detector_stack.rb
reek-1.2.5 lib/reek/detector_stack.rb
reek-1.2.4 lib/reek/detector_stack.rb