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

Conversation

BlakeWilliams
Copy link
Contributor

This uses Ruby's set class
to keep track of which lines in every file is reported to prevent
reporting the same line multiple times.

This happens most frequently with JavaScript since the Babel generated
ast is verbose and can expand a single line into a large s-expression
tree which can have several duplications.

@@ -26,6 +26,10 @@ def format
}
end

def report_name
"#{current_sexp.file}-#{current_sexp.line}"
Copy link
Contributor

Choose a reason for hiding this comment

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

Should this include end line as well?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I was thinking about that myself, and I'm not sure honestly. I don't think there would be any (or very many at the least) instances where the same start line has multiple end-lines.

I'd love to hear what others think about that though.

Copy link
Contributor

Choose a reason for hiding this comment

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

Cool - You know more about this so I defer to you on that!

@gdiggs
Copy link
Contributor

gdiggs commented Nov 9, 2015

LGTM

This uses Ruby's
[`set`](http://ruby-doc.org/stdlib-2.2.3/libdoc/set/rdoc/Set.html) class
to keep track of which lines in every file is reported to prevent
reporting the same line multiple times.

This happens most frequently with JavaScript since the Babel generated
ast is verbose and can expand a single line into a large s-expression
tree which can have several duplications.
@BlakeWilliams BlakeWilliams force-pushed the bmw-single-line-duplications branch from 1892130 to 3db399f Compare November 9, 2015 21:31

result = run_engine(engine_conf).strip
issues = result.split("\0")
expect(issues.length).to eq 1
Copy link
Contributor

Choose a reason for hiding this comment

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

@BlakeWilliams can you explain why this is 1? Is it because we set the mass to 1 for the tests? I wouldn't expect a line to be reported unless there was another instance of it

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yep, it's because we pass in an extremely low mass threshold so this will always be higher.

Copy link
Contributor

Choose a reason for hiding this comment

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

Ok thanks!

gdiggs added a commit that referenced this pull request Nov 9, 2015
Don't report same line for multiple duplications
@gdiggs gdiggs merged commit 8df8109 into master Nov 9, 2015
@gdiggs gdiggs deleted the bmw-single-line-duplications branch November 9, 2015 22:48
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants