From 8a4ae61c3861e534493c41fe6ff0bd621601d846 Mon Sep 17 00:00:00 2001 From: ABaldwinHunter Date: Wed, 27 Jan 2016 17:00:53 -0500 Subject: [PATCH] Include mass in issue description - Increase mass visibility - Increase parity with Code Climate classic duplication reporting The mass is already presented in the issue content readup, but somewhat obfuscated. --- lib/cc/engine/analyzers/violation.rb | 1 + spec/cc/engine/analyzers/javascript/main_spec.rb | 4 ++-- spec/cc/engine/analyzers/php/main_spec.rb | 2 +- spec/cc/engine/analyzers/python/main_spec.rb | 4 ++-- spec/cc/engine/analyzers/ruby/main_spec.rb | 2 +- spec/cc/engine/analyzers/violations_spec.rb | 2 +- 6 files changed, 8 insertions(+), 7 deletions(-) diff --git a/lib/cc/engine/analyzers/violation.rb b/lib/cc/engine/analyzers/violation.rb index 9d4adfde..ebda14d2 100644 --- a/lib/cc/engine/analyzers/violation.rb +++ b/lib/cc/engine/analyzers/violation.rb @@ -93,6 +93,7 @@ def fingerprint def description description = "#{check_name} found in #{occurrences} other location" description += "s" if occurrences > 1 + description += " (mass = #{mass})" description end diff --git a/spec/cc/engine/analyzers/javascript/main_spec.rb b/spec/cc/engine/analyzers/javascript/main_spec.rb index 520fc262..5b361ee5 100644 --- a/spec/cc/engine/analyzers/javascript/main_spec.rb +++ b/spec/cc/engine/analyzers/javascript/main_spec.rb @@ -22,7 +22,7 @@ expect(json["type"]).to eq("issue") expect(json["check_name"]).to eq("Identical code") - expect(json["description"]).to eq("Identical code found in 2 other locations") + expect(json["description"]).to eq("Identical code found in 2 other locations (mass = 11)") expect(json["categories"]).to eq(["Duplication"]) expect(json["location"]).to eq({ "path" => "foo.js", @@ -50,7 +50,7 @@ expect(json["type"]).to eq("issue") expect(json["check_name"]).to eq("Similar code") - expect(json["description"]).to eq("Similar code found in 2 other locations") + expect(json["description"]).to eq("Similar code found in 2 other locations (mass = 11)") expect(json["categories"]).to eq(["Duplication"]) expect(json["location"]).to eq({ "path" => "foo.js", diff --git a/spec/cc/engine/analyzers/php/main_spec.rb b/spec/cc/engine/analyzers/php/main_spec.rb index d2acf31e..083620c8 100644 --- a/spec/cc/engine/analyzers/php/main_spec.rb +++ b/spec/cc/engine/analyzers/php/main_spec.rb @@ -35,7 +35,7 @@ expect(json["type"]).to eq("issue") expect(json["check_name"]).to eq("Identical code") - expect(json["description"]).to eq("Identical code found in 1 other location") + expect(json["description"]).to eq("Identical code found in 1 other location (mass = 11)") expect(json["categories"]).to eq(["Duplication"]) expect(json["location"]).to eq({ "path" => "foo.php", diff --git a/spec/cc/engine/analyzers/python/main_spec.rb b/spec/cc/engine/analyzers/python/main_spec.rb index d6496f93..83ccec8b 100644 --- a/spec/cc/engine/analyzers/python/main_spec.rb +++ b/spec/cc/engine/analyzers/python/main_spec.rb @@ -22,7 +22,7 @@ expect(json["type"]).to eq("issue") expect(json["check_name"]).to eq("Identical code") - expect(json["description"]).to eq("Identical code found in 2 other locations") + expect(json["description"]).to eq("Identical code found in 2 other locations (mass = 6)") expect(json["categories"]).to eq(["Duplication"]) expect(json["location"]).to eq({ "path" => "foo.py", @@ -50,7 +50,7 @@ expect(json["type"]).to eq("issue") expect(json["check_name"]).to eq("Similar code") - expect(json["description"]).to eq("Similar code found in 2 other locations") + expect(json["description"]).to eq("Similar code found in 2 other locations (mass = 6)") expect(json["categories"]).to eq(["Duplication"]) expect(json["location"]).to eq({ "path" => "foo.py", diff --git a/spec/cc/engine/analyzers/ruby/main_spec.rb b/spec/cc/engine/analyzers/ruby/main_spec.rb index bf6d4ec2..24fb8e5f 100644 --- a/spec/cc/engine/analyzers/ruby/main_spec.rb +++ b/spec/cc/engine/analyzers/ruby/main_spec.rb @@ -34,7 +34,7 @@ module CC::Engine::Analyzers expect(json["type"]).to eq("issue") expect(json["check_name"]).to eq("Similar code") - expect(json["description"]).to eq("Similar code found in 1 other location") + expect(json["description"]).to eq("Similar code found in 1 other location (mass = 18)") expect(json["categories"]).to eq(["Duplication"]) expect(json["location"]).to eq({ "path" => "foo.rb", diff --git a/spec/cc/engine/analyzers/violations_spec.rb b/spec/cc/engine/analyzers/violations_spec.rb index 1447f5c0..130bdaba 100644 --- a/spec/cc/engine/analyzers/violations_spec.rb +++ b/spec/cc/engine/analyzers/violations_spec.rb @@ -35,7 +35,7 @@ module CC::Engine::Analyzers expect(first_formatted[:type]).to eq("issue") expect(first_formatted[:check_name]).to eq("Identical code") - expect(first_formatted[:description]).to eq("Identical code found in 2 other locations") + expect(first_formatted[:description]).to eq("Identical code found in 2 other locations (mass = 18)") expect(first_formatted[:categories]).to eq(["Duplication"]) expect(first_formatted[:remediation_points]).to eq(30) expect(first_formatted[:location]).to eq({:path=>"file.rb", :lines=>{:begin=>1, :end=>5}})