Class: ImproveYourCode::DetectorRepository

Inherits:
Object
  • Object
show all
Defined in:
lib/improve_your_code/detector_repository.rb

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(smell_types: self.class.smell_types) ⇒ DetectorRepository

Returns a new instance of DetectorRepository.



13
14
15
# File 'lib/improve_your_code/detector_repository.rb', line 13

def initialize(smell_types: self.class.smell_types)
  @smell_types = smell_types
end

Class Method Details

.eligible_smell_typesObject



8
9
10
11
# File 'lib/improve_your_code/detector_repository.rb', line 8

def self.eligible_smell_types
  ImproveYourCode::SmellDetectors::BaseDetector
    .descendants.sort_by(&:name)
end

Instance Method Details

#examine(context) ⇒ Object



17
18
19
20
21
22
# File 'lib/improve_your_code/detector_repository.rb', line 17

def examine(context)
  smell_detectors_for(context.type).flat_map do |klass|
    detector = klass.new context: context
    detector.run
  end
end