Skip to content
This repository was archived by the owner on Jul 19, 2025. It is now read-only.

Mimic descriptions emitted by classic #17

Merged
merged 1 commit into from
Oct 26, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .ruby-version
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
2.2.3
12 changes: 11 additions & 1 deletion lib/cc/engine/analyzers/violation.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ def format
{
"type": "issue",
"check_name": name,
"description": "Duplication found in #{issue.name}",
"description": description,
"categories": ["Duplication"],
"location": format_location,
"remediation_points": calculate_points,
Expand Down Expand Up @@ -83,6 +83,16 @@ def content_body
read_up = File.read('config/contents/duplicated_code.md')
{ "body": read_up }
end

def description
description = "*Similar code* found in #{occurrences} other location"
description += "s" if occurrences > 1
description
end

def occurrences
other_sexps.count
end
end
end
end
Expand Down
2 changes: 1 addition & 1 deletion spec/cc/engine/analyzers/javascript/main_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ def run_engine(config = nil)
end

def printed_issue
issue = {"type":"issue","check_name":"Identical code","description":"Duplication found in ExpressionStatement","categories":["Duplication"],"location":{"path":"foo.js","lines":{"begin":1,"end":1}},"remediation_points":378000, "other_locations":[{"path":"foo.js","lines":{"begin":2,"end":2}},{"path":"foo.js","lines":{"begin":3,"end":3}}], "content":{"body": read_up}}
issue = {"type":"issue","check_name":"Identical code","description":"*Similar code* found in 2 other locations","categories":["Duplication"],"location":{"path":"foo.js","lines":{"begin":1,"end":1}},"remediation_points":378000, "other_locations":[{"path":"foo.js","lines":{"begin":2,"end":2}},{"path":"foo.js","lines":{"begin":3,"end":3}}], "content":{"body": read_up}}
issue.to_json + "\0\n"
end

Expand Down
2 changes: 1 addition & 1 deletion spec/cc/engine/analyzers/php/main_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ def run_engine(config = nil)
end

def printed_issue
issue = {"type":"issue","check_name":"Identical code","description":"Duplication found in function","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 = {"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

Expand Down
2 changes: 1 addition & 1 deletion spec/cc/engine/analyzers/python/main_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ def run_engine(config = nil)
end

def printed_issue
issue = {"type":"issue","check_name":"Identical code","description":"Duplication found in Print","categories":["Duplication"],"location":{"path":"foo.py","lines":{"begin":1,"end":1}},"remediation_points":81000, "other_locations":[{"path":"foo.py","lines":{"begin":2,"end":2}},{"path":"foo.py","lines":{"begin":3,"end":3}}], "content":{"body": read_up}}
issue = {"type":"issue","check_name":"Identical code","description":"*Similar code* found in 2 other locations","categories":["Duplication"],"location":{"path":"foo.py","lines":{"begin":1,"end":1}},"remediation_points":81000, "other_locations":[{"path":"foo.py","lines":{"begin":2,"end":2}},{"path":"foo.py","lines":{"begin":3,"end":3}}], "content":{"body": read_up}}
issue.to_json + "\0\n"
end

Expand Down
2 changes: 1 addition & 1 deletion spec/cc/engine/analyzers/ruby/main_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ def run_engine(config = {})
end

def first_issue
{"type":"issue","check_name":"Similar code","description":"Duplication found in iter","categories":["Duplication"],"location":{"path":"foo.rb","lines":{"begin":1,"end":5}},"remediation_points": 360000, "other_locations":[{"path":"foo.rb","lines":{"begin":9,"end":13}}], "content": {"body": read_up}}
{"type":"issue","check_name":"Similar code","description":"*Similar code* found in 1 other location","categories":["Duplication"],"location":{"path":"foo.rb","lines":{"begin":1,"end":5}},"remediation_points": 360000, "other_locations":[{"path":"foo.rb","lines":{"begin":9,"end":13}}], "content": {"body": read_up}}
end

def printed_issues
Expand Down