Sha256: 504e9e3adbbb3bb60a955e0af22cf090152b0509d986f02e6697cd9fb59fc7bc

Contents?: true

Size: 950 Bytes

Versions: 8

Compression:

Stored size: 950 Bytes

Contents

require 'reek/core/code_parser'
require 'reek/core/smell_repository'
require 'reek/configuration/app_configuration'

module Reek
  module Core
    #
    # Configures all available smell detectors and applies them to a source.
    #
    class Sniffer
      def initialize(source, # Either Source::SourceFile or Source::SourceCode
                     smell_repository = Core::SmellRepository.new(source.desc))
        @smell_repository = smell_repository
        @source = source

        Configuration::AppConfiguration.configure_smell_repository(@smell_repository)
      end

      def report_on(listener)
        CodeParser.new(@smell_repository).process(syntax_tree) if syntax_tree
        @smell_repository.report_on(listener)
      end

      def examine(scope, node_type)
        @smell_repository.examine scope, node_type
      end

      private

      def syntax_tree
        @syntax_tree ||= @source.syntax_tree
      end
    end
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
reek-2.0.0 lib/reek/core/sniffer.rb
reek-1.6.6 lib/reek/core/sniffer.rb
reek-1.6.5 lib/reek/core/sniffer.rb
reek-1.6.4 lib/reek/core/sniffer.rb
reek-1.6.3 lib/reek/core/sniffer.rb
reek-1.6.2 lib/reek/core/sniffer.rb
reek-1.6.1 lib/reek/core/sniffer.rb
reek-1.6.0 lib/reek/core/sniffer.rb