Sha256: 225ba71fd7ace4cc27e420ed78870cfedf85755f57e38182382eb5333f9336e0

Contents?: true

Size: 1.86 KB

Versions: 1

Compression:

Stored size: 1.86 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::NilCheck,
          Smells::SimulatedPolymorphism,
          Smells::UncommunicativeMethodName,
          Smells::UncommunicativeModuleName,
          Smells::UncommunicativeParameterName,
          Smells::UncommunicativeVariableName,
          Smells::UnusedParameters,
          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

1 entries across 1 versions & 1 rubygems

Version Path
reek-1.3.1 lib/reek/core/smell_repository.rb