Skip to content
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

False negative for RC_REF_COMPARISON #2297

Closed
harrisric opened this issue Jan 4, 2023 · 4 comments
Closed

False negative for RC_REF_COMPARISON #2297

harrisric opened this issue Jan 4, 2023 · 4 comments
Assignees

Comments

@harrisric
Copy link

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 +"]");
    }
  }

}
@welcome
Copy link

welcome bot commented Jan 4, 2023

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.

@harrisric
Copy link
Author

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.

@yuliyasokh
Copy link
Contributor

Hello All, I’ll be happy to pick it up and make corresponding changes in documentation

hazendaz pushed a commit that referenced this issue Aug 27, 2023
…in RC_REF_COMPARISON description (#2537)

* Not able to detect SE_NO_SERIALVERSIONID bug - added unit test

* Not able to detect SE_NO_SERIALVERSIONID bug - added unit test- change package and add bug type

* Not able to detect SE_NO_SERIALVERSIONID bug - added unit test- removed excessive function

* A false negative about the rule IL_INFINITE_LOOP #2331 - added unit test

* Issue-2331 added missing space

* Issue-2297 False negative for RC REF COMPARISON - updated bug description

* Issue-2297 False negative for RC REF COMPARISON - add changed log record

* Issue-2297 False negative for RC REF COMPARISON - corrected typo

* Issue-2297 False negative for RC REF COMPARISON - escaped tags

---------

Co-authored-by: yuliya.sokh@gmail.com <21014151y>
@hazendaz
Copy link
Member

Closing as a documentation issue resolved now with #2537

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants