-
Notifications
You must be signed in to change notification settings - Fork 578
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
SA_LOCAL_SELF_COMPUTATION bug #1472
Comments
gloNelson
changed the title
SA_LOCAL_SELF_COMPUTATION bug and potential false negative
SA_LOCAL_SELF_COMPUTATION bug
Mar 24, 2021
Another problematic code section in FindSelfComparison.java is mentioned in #1473 (False negatives on SA_FIELD_SELF_COMPUTATION and SA_LOCAL_SELF_COMPUTATION) in detail. Thanks a lot. @KengoTODA |
1 task
I have created a pull request to fix this. Please help me review this :) @KengoTODA Thks! |
gloNelson
added a commit
to gloNelson/spotbugs
that referenced
this issue
Mar 28, 2021
Fixed by #1478, thank you! |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hi,
I read SA_LOCAL_SELF_COMPUTATION on SpotBugs Bug Description page, which mentions that this method performs a nonsensical computation of a local variable with another reference to the same variable (e.g.,
x&x
orx-x
).So, I wrote test cases as below.
It can be seen from the results that only
^
will trigger SpotBugs to report SA_LOCAL_SELF_COMPUTATION, while other operators will not.I tried to search test cases of SA_LOCAL_SELF_COMPUTATION in SpotBugs source code and found several test cases of SA_FIELD_SELF_COMPUTATION which detect self computation of field instead of local variables.
Similar test-cases for SA_FIELD_SELF_COMPUTATION executed and all four output SA_FIELD_SELF_COMPUTATION errors report.
Finally, I realized that the fault is in line 325 of FindSelfComparison.java.
The code shows that SpotBugs reports SA_FIELD_SELF_COMPUTATION only when
opCode
equalsConst.IXOR
(^
).It is so confusing that self computation detection of
local variables
only including^
operator while the detection offield
supports much more. Is it a bug?The text was updated successfully, but these errors were encountered: