From c2ae13d6403d62eeef7d7db88e675388cd9c0c52 Mon Sep 17 00:00:00 2001 From: ABaldwinHunter Date: Fri, 15 Jan 2016 18:34:39 -0500 Subject: [PATCH 1/2] Include mass in issue description - Increase parity with Code Climate classic duplication reporting - Make mass more salient The mass is already presented in the issue content readup, but it's lost in a sea of non-custom text. --- lib/cc/engine/analyzers/violation.rb | 2 +- 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 +- 5 files changed, 7 insertions(+), 7 deletions(-) diff --git a/lib/cc/engine/analyzers/violation.rb b/lib/cc/engine/analyzers/violation.rb index 4f39fbf1..52269cf8 100644 --- a/lib/cc/engine/analyzers/violation.rb +++ b/lib/cc/engine/analyzers/violation.rb @@ -98,7 +98,7 @@ def fingerprint def description description = "#{check_name} found in #{occurrences} other location" description += "s" if occurrences > 1 - description + description += " (mass = #{issue.mass})" end def occurrences diff --git a/spec/cc/engine/analyzers/javascript/main_spec.rb b/spec/cc/engine/analyzers/javascript/main_spec.rb index 3fa0517b..58bb7715 100644 --- a/spec/cc/engine/analyzers/javascript/main_spec.rb +++ b/spec/cc/engine/analyzers/javascript/main_spec.rb @@ -21,7 +21,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 = 99)") expect(json["categories"]).to eq(["Duplication"]) expect(json["location"]).to eq({ "path" => "foo.js", @@ -48,7 +48,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 = 33)") 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 c6898473..831eb1fc 100644 --- a/spec/cc/engine/analyzers/php/main_spec.rb +++ b/spec/cc/engine/analyzers/php/main_spec.rb @@ -34,7 +34,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 = 44)") 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 9c3da701..c81acc6f 100644 --- a/spec/cc/engine/analyzers/python/main_spec.rb +++ b/spec/cc/engine/analyzers/python/main_spec.rb @@ -21,7 +21,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 = 54)") expect(json["categories"]).to eq(["Duplication"]) expect(json["location"]).to eq({ "path" => "foo.py", @@ -48,7 +48,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 = 18)") 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 b3af3bac..1fb88ec3 100644 --- a/spec/cc/engine/analyzers/ruby/main_spec.rb +++ b/spec/cc/engine/analyzers/ruby/main_spec.rb @@ -33,7 +33,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 = 36)") expect(json["categories"]).to eq(["Duplication"]) expect(json["location"]).to eq({ "path" => "foo.rb", From cf57d116b817fd75fb9d201f91630ba90c5751fa Mon Sep 17 00:00:00 2001 From: ABaldwinHunter Date: Fri, 15 Jan 2016 18:37:02 -0500 Subject: [PATCH 2/2] Remove unused method from spec --- spec/cc/engine/analyzers/php/main_spec.rb | 5 ----- 1 file changed, 5 deletions(-) diff --git a/spec/cc/engine/analyzers/php/main_spec.rb b/spec/cc/engine/analyzers/php/main_spec.rb index 831eb1fc..2e4cdeeb 100644 --- a/spec/cc/engine/analyzers/php/main_spec.rb +++ b/spec/cc/engine/analyzers/php/main_spec.rb @@ -91,11 +91,6 @@ end end - def printed_issue - issue = {"type":"issue","check_name":"Identical code","description":"Similar code found in 1 other location","categories":["Duplication"],"location":{"path":"foo.php","lines":{"begin":2,"end":6}},"remediation_points":176000,"other_locations":[{"path":"foo.php","lines":{"begin":10,"end":14}}],"content":{"body": read_up}} - issue.to_json + "\0\n" - end - def engine_conf CC::Engine::Analyzers::EngineConfig.new({ 'config' => {