Sha256: ddd49f50ab5dcd3c143053e1af505a041a0ff2804d9afa53eb1a497c2a379d90

Contents?: true

Size: 876 Bytes

Versions: 2

Compression:

Stored size: 876 Bytes

Contents

require "rubycritic/smell"

module Rubycritic
  module SmellAdapter

    class Flog
      def initialize(flog)
        @flog = flog
      end

      def smells
        smells = []
        @flog.each_by_score do |class_method, score|
          smells << create_smell(class_method, score)
        end
        smells
      end

      private

      def create_smell(context, score)
        location = smell_location(context)
        message  = "has a complexity of #{score.round}"

        Smell.new(
          :locations => [location],
          :context => context,
          :message => message,
          :score => score,
          :type => "Complexity"
        )
      end

      def smell_location(context)
        line = @flog.method_locations[context]
        file_path, file_line = line.split(":")
        Location.new(file_path, file_line)
      end
    end

  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
rubycritic-0.0.8 lib/rubycritic/smell_adapters/flog.rb
rubycritic-0.0.7 lib/rubycritic/smell_adapters/flog.rb