lib/pronto/flay.rb in pronto-flay-0.4.0 vs lib/pronto/flay.rb in pronto-flay-0.4.1
- old
+ new
@@ -9,13 +9,13 @@
def run(patches, _)
return [] unless patches
ruby_patches = patches.select { |patch| patch.additions > 0 }
- .select { |patch| ruby_file?(patch.new_file_full_path) }
+ .select { |patch| ruby_file?(patch.new_file_full_path) }
- files = ruby_patches.map { |patch| File.new(patch.new_file_full_path) }
+ files = ruby_patches.map(&:new_file_full_path)
if files.any?
@flay.process(*files)
@flay.analyze
messages_for(ruby_patches)
@@ -36,17 +36,18 @@
end.flatten.compact
end
def patch_for_node(ruby_patches, node)
ruby_patches.find do |patch|
- patch.new_file_full_path.to_s == node.file.path
+ patch.new_file_full_path == node.file
end
end
def new_message(line, node)
+ path = line.patch.delta.new_file[:path]
hash = node.structural_hash
- Message.new(line.patch.delta.new_file[:path], line, level(hash), message(hash))
+ Message.new(path, line, level(hash), message(hash))
end
def level(hash)
same?(hash) ? :error : :warning
end
@@ -56,10 +57,10 @@
end
def message(hash)
match = same?(hash) ? 'Identical' : 'Similar'
location = nodes_for(hash).map do |node|
- "#{File.basename(node.file.path)}:#{node.line}"
+ "#{File.basename(node.file)}:#{node.line}"
end
"#{match} code found in #{location.join(', ')}"
end