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
Report bug SA_FIELD_SELF_ASSIGNMENT
in nested classes as well
#2161
Conversation
Bug `SA_FIELD_SELF_ASSIGNMENT` was not reported in nested classes, only in the outer class. This lead to inconsistent behavior. See issue ([spotbugs#2142](spotbugs#2142)). This PR fixes this issue.
spotbugs/src/main/java/edu/umd/cs/findbugs/detect/FindFieldSelfAssignment.java
Outdated
Show resolved
Hide resolved
spotbugs/src/main/java/edu/umd/cs/findbugs/detect/FindFieldSelfAssignment.java
Outdated
Show resolved
Hide resolved
public void afterOpcode(int seen) { | ||
super.afterOpcode(seen); | ||
|
||
if (seen == Const.GETFIELD && parentInstanceLoadFromRegister > -1) { |
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.
Could you replace this magic number -1
with a static final int
field?
Better to tell our intention to who is reading our code.
spotbugs/src/main/java/edu/umd/cs/findbugs/detect/FindFieldSelfAssignment.java
Show resolved
Hide resolved
…fAssignment.java Co-authored-by: Kengo TODA <skypencil+github@gmail.com>
…fAssignment.java Co-authored-by: Kengo TODA <skypencil+github@gmail.com>
Thank you for your comments, @KengoTODA! I think I fixed every one of them now. |
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.
LGTM, thank you!
Bug
SA_FIELD_SELF_ASSIGNMENT
was not reported in nested classes, only in the outer class. This lead to inconsistent behavior. See issue (#2142). This PR fixes this issue.Make sure these boxes are checked before submitting your PR -- thank you!
CHANGELOG.md
if you have changed SpotBugs code