False negative for RC_REF_COMPARISON
harrisric opened this issue · comments
I'm not sure if it is the intention of the RC_REF_COMPARISON bug detector to pick up all cases of reference comparison but the following very simple examples are not caught.
import java.time.LocalDate;
public class RefComparisonTestClass {
private final LocalDate date1 = LocalDate.now();
public boolean isSameDate(LocalDate date2) {
return date1 == date2;
}
public void logIfSameDate(LocalDate date2) {
if (date1 != date2) {
System.out.println("Dates not the same [" + date1 + "], [" + date2 +"]");
}
}
}
Thanks for opening your first issue here! 😃
Please check our contributing guideline. Especially when you report a problem, make sure you share a Minimal, Complete, and Verifiable example to reproduce it in this issue.
Apologies - I have found that this can be picked up by an undocumented configuration option.
<plugin>
<groupId>com.github.spotbugs</groupId>
<artifactId>spotbugs-maven-plugin</artifactId>
<version>4.7.3.0</version>
<configuration>
...
<systemPropertyVariables>
<frc.suspicious>java.time.LocalDate</frc.suspicious>
</systemPropertyVariables>
</configuration>
It would be good if the documentation could be improved to include this information. Happy to help if this is something I can do.
Hello All, I’ll be happy to pick it up and make corresponding changes in documentation
Closing as a documentation issue resolved now with #2537