-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Identical Expression Comparison analyzer #7066
Merged
prylabs-bulldozer
merged 11 commits into
master
from
identical-expression-comparison-analyzer
Aug 21, 2020
Merged
Identical Expression Comparison analyzer #7066
prylabs-bulldozer
merged 11 commits into
master
from
identical-expression-comparison-analyzer
Aug 21, 2020
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This reverts commit e9ccea7.
rkapka
commented
Aug 21, 2020
], | ||
) | ||
|
||
# gazelle:exclude analyzer_test.go |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Had to ignore tests because of #7074
Codecov Report
@@ Coverage Diff @@
## master #7066 +/- ##
==========================================
+ Coverage 60.07% 62.20% +2.13%
==========================================
Files 323 404 +81
Lines 27422 31502 +4080
==========================================
+ Hits 16473 19595 +3122
- Misses 8733 9125 +392
- Partials 2216 2782 +566 |
rauljordan
approved these changes
Aug 21, 2020
rkapka
changed the title
Identical expression comparison analyzer
Identical Expression Comparison analyzer
Sep 16, 2020
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
What type of PR is this?
Tool
What does this PR do? Why is it needed?
This PR introduces a static code analyzer that reports a diagnostic when a boolean comparison expression (
==
,!=
,>=
,<=
,>
,<
) is comparing two identical expressions. Occurrences of such code in Prysm have been found here: https://deepsource.io/gh/rkapka/prysm/issue/SCC-SA4000/occurrences. This is especially bad in tests because an assertion such asx == x
will always pass, even if the tested code becomes broken.Which issues(s) does this PR fix?
Part of #6747
Other notes for review
This PR will likely fail to build because of the mentioned occurrences. Please add commits to this branch with fixes because I don't know what the correct expressions should be.