Sha256: 5a68173b406d541cec3c9638a6f238ff230e45807906dbe03c34ae5c3782aa64

Contents?: true

Size: 1.78 KB

Versions: 4

Compression:

Stored size: 1.78 KB

Contents

require File.join(File.dirname(File.dirname(File.expand_path(__FILE__))), 'smells')

module Reek
  module Core
    class SmellRepository

      def self.smell_classes
        # SMELL: Duplication -- these should be loaded by listing the files
        [
         Smells::Attribute,
         Smells::BooleanParameter,
         Smells::ClassVariable,
         Smells::ControlCouple,
         Smells::DataClump,
         Smells::Duplication,
         Smells::FeatureEnvy,
         Smells::IrresponsibleModule,
         Smells::LargeClass,
         Smells::LongMethod,
         Smells::LongParameterList,
         Smells::LongYieldList,
         Smells::NestedIterators,
         Smells::SimulatedPolymorphism,
         Smells::UncommunicativeMethodName,
         Smells::UncommunicativeModuleName,
         Smells::UncommunicativeParameterName,
         Smells::UncommunicativeVariableName,
         Smells::UtilityFunction,
        ]
      end

      def initialize source_description
        @typed_detectors = nil
        @detectors = Hash.new
        SmellRepository.smell_classes.each do |klass|
          @detectors[klass] = klass.new(source_description)
        end
      end

      def configure(klass, config)
        @detectors[klass].configure_with(config)
      end

      def report_on listener
        @detectors.each_value { |detector| detector.report_on(listener) }
      end

      def examine(scope, node_type)
        smell_listeners[node_type].each do |detector|
          detector.examine(scope)
        end
      end

      private

      def smell_listeners()
        unless @typed_detectors
          @typed_detectors = Hash.new {|hash,key| hash[key] = [] }
          @detectors.each_value { |detector| detector.register(@typed_detectors) }
        end
        @typed_detectors
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
reek-1.2.12 lib/reek/core/smell_repository.rb
reek-1.2.11 lib/reek/core/smell_repository.rb
reek-1.2.10 lib/reek/core/smell_repository.rb
reek-1.2.9 lib/reek/core/smell_repository.rb