Commit f8d66412 authored by Coraline Ehmke's avatar Coraline Ehmke

Line numbers in CSV output

parent 3952a4d8
......@@ -6,8 +6,8 @@ may be extracted from a given class.
## TODO
* Report cohorts with line numbers
* Ignore data clumps called in "loose" class methods (e.g. attr_accessor)
* Match on string concatenation
* Consider weighting based on match type
## Installation
......
......@@ -6,7 +6,7 @@ module Snuffle
attr_accessor :element, :neighbors, :line_numbers
def self.from(nodes)
Element::Hash.materialize(nodes.hashes.to_a).inject([]) do |cohorts, element|
cohorts = Element::Hash.materialize(nodes.hashes.to_a).inject([]) do |cohorts, element|
cohort = Cohort.new(element: element, line_numbers: element.node.line_numbers )
cohorts << cohort if cohort.values.count > 1 && cohort.near_neighbors.count > 0
cohorts
......@@ -22,7 +22,7 @@ module Snuffle
end
def neighbors
@neighbors ||= element.node.siblings.map{|sibling| Element::Hash.materialize([sibling]).first}
@neighbors ||= [element.node.siblings - [self.element.node]].flatten.map{|sibling| Element::Hash.materialize([sibling]).first}
end
def values
......
......@@ -10,8 +10,11 @@ module Snuffle
end
def rows
summary.object_candidates.map do |candidate|
[summary.path_to_file, summary.class_name, "##{candidate.join(" #")}"].join(',')
# summary.object_candidates.map do |candidate|
# [summary.path_to_file, summary.class_name, "##{candidate.join(" #")}"].join(',')
# end
summary.cohorts.group_by{|c| c.values}.map do |cohort|
[summary.path_to_file, summary.class_name, cohort[0].join("; "), cohort[1].map(&:line_numbers).join("; ")].join(',')
end
end
......
......@@ -29,7 +29,7 @@
= summary.path_to_file
%h3.indented
Potential objects:
Candidate object attributes:
%ul.indented
- summary.cohorts.group_by{|c| c.values.sort }.each do |values, cohorts|
......@@ -37,7 +37,7 @@
%li
= values.map{|c| "##{c}" }.join(", ")
%br
= "Lines #{cohorts.map(&:line_numbers).join(', ')}"
= "Line(s): #{cohorts.map(&:line_numbers).join(', ')}"
= source_lines
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment