Sha256: aecb62c4bb89b88b278e892d42ecf0a9396e947ba244f3e74639559a95befac2
Contents?: true
Size: 1.01 KB
Versions: 2
Compression:
Stored size: 1.01 KB
Contents
require "rubycritic/analysers/flay" require "rubycritic/smell" module Rubycritic module SmellAdapter class Flay def initialize(paths) @flay = ::Rubycritic::Analyser::Flay.new(paths) end def smells @flay.hashes.map do |structural_hash, nodes| create_smell(structural_hash, nodes) end end private def create_smell(structural_hash, nodes) Smell.new( :locations => smell_locations(nodes), :context => "#{similarity(structural_hash)} code", :message => "found in #{nodes.size} nodes", :score => @flay.masses[structural_hash], :type => "DuplicateCode" ) end def smell_locations(nodes) nodes.map do |node| Location.new(node.file, node.line) end.sort end def similarity(structural_hash) if @flay.identical[structural_hash] "Identical" else "Similar" end end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
rubycritic-0.0.12 | lib/rubycritic/adapters/smell/flay.rb |
rubycritic-0.0.11 | lib/rubycritic/smell_adapters/flay.rb |