Sha256: 5bd19cc05ed264fdf58c2abb6497f9527ae03528fe33a48d81c44a4934732302
Contents?: true
Size: 1001 Bytes
Versions: 3
Compression:
Stored size: 1001 Bytes
Contents
require "rubycritic/smell" module Rubycritic module SmellAdapter class Flay def initialize(flay) @flay = flay end def smells @flay.hashes.map do |structural_hash, nodes| create_smell(structural_hash, nodes) end end private def create_smell(structural_hash, nodes) is_identical = @flay.identical[structural_hash] similarity = is_identical ? "Identical" : "Similar" locations = smell_locations(nodes) context = "#{similarity} code" message = "found in #{nodes.size} nodes" score = @flay.masses[structural_hash] Smell.new( :locations => locations, :context => context, :message => message, :score => score, :type => "DuplicateCode" ) end def smell_locations(nodes) nodes.map do |node| Location.new(node.file, node.line) end.sort end end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
rubycritic-0.0.9 | lib/rubycritic/smell_adapters/flay.rb |
rubycritic-0.0.8 | lib/rubycritic/smell_adapters/flay.rb |
rubycritic-0.0.7 | lib/rubycritic/smell_adapters/flay.rb |