Skip to content

Fix fingerprint bug - don't use num occurrences #92

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jan 29, 2016
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
2 changes: 1 addition & 1 deletion lib/cc/engine/analyzers/violation.rb
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ def fingerprint
digest << "-"
digest << current_sexp.mass.to_s
digest << "-"
digest << occurrences.to_s
digest << check_name
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Classic also uses the type of the sexp's root node, I think. That's an extra piece of info to make the fingerprint more unique that may be worth adding.

digest.to_s
end

Expand Down
4 changes: 2 additions & 2 deletions spec/cc/engine/analyzers/javascript/main_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
{"path" => "foo.js", "lines" => { "begin" => 3, "end" => 3} }
])
expect(json["content"]["body"]).to match /This issue has a mass of `11`/
expect(json["fingerprint"]).to eq("55ae5d0990647ef496e9e0d315f9727d")
expect(json["fingerprint"]).to eq("c4d29200c20d02297c6f550ad2c87c15")
end

it "prints an issue for similar code" do
Expand Down Expand Up @@ -62,7 +62,7 @@
{"path" => "foo.js", "lines" => { "begin" => 3, "end" => 3} }
])
expect(json["content"]["body"]).to match /This issue has a mass of `11`/
expect(json["fingerprint"]).to eq("55ae5d0990647ef496e9e0d315f9727d")
expect(json["fingerprint"]).to eq("d9dab8e4607e2a74da3b9eefb49eacec")
end

it "skips unparsable files" do
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 @@ -45,7 +45,7 @@
{"path" => "foo.php", "lines" => { "begin" => 10, "end" => 14} },
])
expect(json["content"]["body"]).to match /This issue has a mass of `11`/
expect(json["fingerprint"]).to eq("667da0e2bab866aa2fe9d014a65d57d9")
expect(json["fingerprint"]).to eq("8234e10d96fd6ef608085c22c91c9ab1")
end

it "runs against complex files" do
Expand Down
4 changes: 2 additions & 2 deletions spec/cc/engine/analyzers/python/main_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
{"path" => "foo.py", "lines" => { "begin" => 3, "end" => 3} }
])
expect(json["content"]["body"]).to match /This issue has a mass of `6`/
expect(json["fingerprint"]).to eq("42b832387c997f54a2012efb2159aefc")
expect(json["fingerprint"]).to eq("3f3d34361bcaef98839d9da6ca9fcee4")
end

it "prints an issue for similar code" do
Expand Down Expand Up @@ -60,7 +60,7 @@
{"path" => "foo.py", "lines" => { "begin" => 3, "end" => 3} }
])
expect(json["content"]["body"]).to match /This issue has a mass of `6`/
expect(json["fingerprint"]).to eq("42b832387c997f54a2012efb2159aefc")
expect(json["fingerprint"]).to eq("019118ceed60bf40b35aad581aae1b02")
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 @@ -44,7 +44,7 @@ module CC::Engine::Analyzers
{"path" => "foo.rb", "lines" => { "begin" => 9, "end" => 13} },
])
expect(json["content"]["body"]).to match /This issue has a mass of `18`/
expect(json["fingerprint"]).to eq("f21b75bbd135ec3ae6638364d5c73762")
expect(json["fingerprint"]).to eq("b7e46d8f5164922678e48942e26100f2")
end

it "creates an issue for each occurrence of the duplicated code" do
Expand Down
2 changes: 1 addition & 1 deletion spec/cc/engine/analyzers/violations_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ module CC::Engine::Analyzers
{ :path => "file.rb", :lines => { :begin => 9, :end => 13} },
{ :path => "file.rb", :lines => { :begin => 17, :end => 21} },
])
expect(first_formatted[:fingerprint]).to eq("c2712b56bff2becf4ae2a8469e1171c7")
expect(first_formatted[:fingerprint]).to eq("f52d2f61a77c569513f8b6314a00d013")

expect(second_formatted[:location]).to eq({:path=>"file.rb", :lines=>{:begin=>9, :end=>13}})
expect(second_formatted[:other_locations]).to eq([
Expand Down