We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
BoxedPrimitiveEquality
For BoxedPrimitiveEquality, if either side of the == is a static final constant, it's not considered a match.
==
For example, for the code
public void test(Boolean bool) { final Boolean bool2 = Boolean.FALSE; boolean result = bool == bool2; }
there is a match: error: [BoxedPrimitiveEquality] Comparison using reference equality instead of value equality.
error: [BoxedPrimitiveEquality] Comparison using reference equality instead of value equality
On the other hand, for
public void test(Boolean bool) { boolean result = bool == Boolean.FALSE; }
there is no match.
Note that this special handling for constants does not occur for ReferenceEquality, so both of the above pieces of code match ReferenceEquality.
ReferenceEquality
Would it be possible to reconsider this special handling? Shouldn't comparing boxed primitives with == be an error in every situation?
I'm using errorprone version 2.36.0.
2.36.0
The text was updated successfully, but these errors were encountered:
Thanks, we agree. We took a look over existing violations of the stricter form of the check, and none of them look like a good idea to allow.
Sorry, something went wrong.
Remove the static constant exemption from BoxedPrimitiveEquality.
c8fba83
I found myself agreeing with #4796. All the findings look bad: unknown commit PiperOrigin-RevId: 721764250
96a3934
I found myself agreeing with #4796. All the findings look bad: unknown commit PiperOrigin-RevId: 722600371
Thank you. Really appreciate this fast response.
No branches or pull requests
For
BoxedPrimitiveEquality
, if either side of the==
is a static final constant, it's not considered a match.For example, for the code
there is a match:
error: [BoxedPrimitiveEquality] Comparison using reference equality instead of value equality
.On the other hand, for
there is no match.
Note that this special handling for constants does not occur for
ReferenceEquality
, so both of the above pieces of code matchReferenceEquality
.Would it be possible to reconsider this special handling? Shouldn't comparing boxed primitives with
==
be an error in every situation?I'm using errorprone version
2.36.0
.The text was updated successfully, but these errors were encountered: