Skip to content

Commit

Permalink
test: reproducer for issue spotbugs#2558
Browse files Browse the repository at this point in the history
  • Loading branch information
gtoison committed Nov 10, 2023
1 parent 00bd670 commit b904fc3
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
package edu.umd.cs.findbugs.detect;

import static edu.umd.cs.findbugs.test.CountMatcher.containsExactly;
import static org.hamcrest.MatcherAssert.assertThat;

import org.junit.jupiter.api.Test;

import edu.umd.cs.findbugs.AbstractIntegrationTest;
import edu.umd.cs.findbugs.test.matcher.BugInstanceMatcher;
import edu.umd.cs.findbugs.test.matcher.BugInstanceMatcherBuilder;


public class Issue2558Test extends AbstractIntegrationTest {
@Test
public void test() {
performAnalysis("ghIssues/Issue2558.class");

BugInstanceMatcher bugTypeMatcher = new BugInstanceMatcherBuilder()
.bugType("NP_EQUALS_SHOULD_HANDLE_NULL_ARGUMENT")
.build();

assertThat(getBugCollection(), containsExactly(0, bugTypeMatcher));
}
}
11 changes: 11 additions & 0 deletions spotbugsTestCases/src/java/ghIssues/Issue2558.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package ghIssues;

public class Issue2558 {

public boolean equals(@edu.umd.cs.findbugs.annotations.NonNull Object a) { //report a warning, but it is an FP
return a.hashCode() == this.hashCode();
}
public boolean something(Issue2558 a, Issue2558 b) {
return a.equals(b);
}
}

0 comments on commit b904fc3

Please sign in to comment.