Sha256: 77fc45ce83420f0be20e157b01f3759a84cd9d99468de9ec9fc31a915613a331

Contents?: true

Size: 1 KB

Versions: 4

Compression:

Stored size: 1 KB

Contents

require "rubycritic/analysers/helpers/reek"
require "rubycritic/core/smell"

module Rubycritic
  module Analyser

    class ReekSmells
      def initialize(analysed_modules)
        @analysed_modules = analysed_modules
      end

      def run
        @analysed_modules.each do |analysed_module|
          add_smells_to(analysed_module)
        end
      end

      private

      def add_smells_to(analysed_module)
        Reek.new(analysed_module.pathname).smells.each do |smell|
          analysed_module.smells << create_smell(smell)
        end
      end

      def create_smell(smell)
        Smell.new(
          :locations => smell_locations(smell.source, smell.lines),
          :context   => smell.context,
          :message   => smell.message,
          :type      => smell.smell_type,
          :cost      => 0
        )
      end

      def smell_locations(file_path, file_lines)
        file_lines.uniq.map do |file_line|
          Location.new(file_path, file_line)
        end.sort
      end
    end

  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
rubycritic-2.3.0 lib/rubycritic/analysers/smells/reek.rb
rubycritic-2.2.0 lib/rubycritic/analysers/smells/reek.rb
rubycritic-2.1.0 lib/rubycritic/analysers/smells/reek.rb
rubycritic-2.0.0 lib/rubycritic/analysers/smells/reek.rb