-
Notifications
You must be signed in to change notification settings - Fork 592
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(deps): update dependency org.apache.bcel:bcel to v6.8.0 (#2756)
* fix(deps): update dependency org.apache.bcel:bcel to v6.8.0 * Fixes for the bcel update (#2757) * Partial fix org.apache.bcel:bcel dependency update (#2446) * Refactor deprecated tests to the new type * Follow the changes in ConstantPool --------- Co-authored-by: Judit Knoll <[email protected]> * migrate the tests to junit jupiter --------- Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> Co-authored-by: Judit Knoll <[email protected]>
- Loading branch information
1 parent
c176966
commit a7aada2
Showing
13 changed files
with
230 additions
and
41 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
56 changes: 56 additions & 0 deletions
56
spotbugs-tests/src/test/java/edu/umd/cs/findbugs/detect/Bug3107916Test.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
package edu.umd.cs.findbugs.detect; | ||
|
||
import edu.umd.cs.findbugs.AbstractIntegrationTest; | ||
import edu.umd.cs.findbugs.test.matcher.BugInstanceMatcher; | ||
import edu.umd.cs.findbugs.test.matcher.BugInstanceMatcherBuilder; | ||
import org.junit.jupiter.api.Test; | ||
|
||
import static edu.umd.cs.findbugs.test.CountMatcher.containsExactly; | ||
import static org.hamcrest.MatcherAssert.assertThat; | ||
import static org.hamcrest.Matchers.hasItem; | ||
|
||
class Bug3107916Test extends AbstractIntegrationTest { | ||
@Test | ||
void test() { | ||
performAnalysis("sfBugs/Bug3107916.class"); | ||
|
||
assertNpBugInMethod("doCompare", 20); | ||
assertNoNpBugInMethod("doCompare2"); | ||
} | ||
|
||
private void assertNoNpBugInMethod(String method) { | ||
final String[] bugtypes = new String[] { | ||
"NP_SYNC_AND_NULL_CHECK_FIELD", "NP_BOOLEAN_RETURN_NULL", "NP_OPTIONAL_RETURN_NULL", | ||
"NP_NONNULL_FIELD_NOT_INITIALIZED_IN_CONSTRUCTOR", "NP_ARGUMENT_MIGHT_BE_NULL", | ||
"NP_EQUALS_SHOULD_HANDLE_NULL_ARGUMENT", "NP_DEREFERENCE_OF_READLINE_VALUE", | ||
"NP_IMMEDIATE_DEREFERENCE_OF_READLINE", "NP_UNWRITTEN_FIELD", "NP_UNWRITTEN_PUBLIC_OR_PROTECTED_FIELD", | ||
"NP_ALWAYS_NULL", "NP_CLOSING_NULL", "NP_STORE_INTO_NONNULL_FIELD", "NP_ALWAYS_NULL_EXCEPTION", | ||
"NP_PARAMETER_MUST_BE_NONNULL_BUT_MARKED_AS_NULLABLE", "NP_NULL_ON_SOME_PATH_FROM_RETURN_VALUE", | ||
"NP_NULL_ON_SOME_PATH_MIGHT_BE_INFEASIBLE", "NP_NULL_ON_SOME_PATH", "NP_NULL_ON_SOME_PATH_EXCEPTION", | ||
"NP_NULL_PARAM_DEREF", "NP_NULL_PARAM_DEREF_NONVIRTUAL", "NP_NULL_PARAM_DEREF_ALL_TARGETS_DANGEROUS", | ||
"NP_NONNULL_PARAM_VIOLATION", "NP_NONNULL_RETURN_VIOLATION", "NP_TOSTRING_COULD_RETURN_NULL", | ||
"NP_CLONE_COULD_RETURN_NULL", "NP_LOAD_OF_KNOWN_NULL_VALUE", "NP_GUARANTEED_DEREF", | ||
"NP_GUARANTEED_DEREF_ON_EXCEPTION_PATH", "NP_NULL_INSTANCEOF", "BC_NULL_INSTANCEOF", | ||
"NP_METHOD_RETURN_RELAXING_ANNOTATION", "NP_METHOD_PARAMETER_TIGHTENS_ANNOTATION", | ||
"NP_METHOD_PARAMETER_RELAXING_ANNOTATION", | ||
}; | ||
for (String bugtype : bugtypes) { | ||
final BugInstanceMatcher bugInstanceMatcher = new BugInstanceMatcherBuilder() | ||
.bugType(bugtype) | ||
.inClass("Bug3107916") | ||
.inMethod(method) | ||
.build(); | ||
assertThat(getBugCollection(), containsExactly(0, bugInstanceMatcher)); | ||
} | ||
} | ||
|
||
private void assertNpBugInMethod(String method, int line) { | ||
final BugInstanceMatcher bugInstanceMatcher = new BugInstanceMatcherBuilder() | ||
.bugType("NP_NULL_ON_SOME_PATH_MIGHT_BE_INFEASIBLE") | ||
.inClass("Bug3107916") | ||
.inMethod(method) | ||
.atLine(line) | ||
.build(); | ||
assertThat(getBugCollection(), hasItem(bugInstanceMatcher)); | ||
} | ||
} |
56 changes: 56 additions & 0 deletions
56
spotbugs-tests/src/test/java/edu/umd/cs/findbugs/detect/Bug3277814Test.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
package edu.umd.cs.findbugs.detect; | ||
|
||
import edu.umd.cs.findbugs.AbstractIntegrationTest; | ||
import edu.umd.cs.findbugs.test.matcher.BugInstanceMatcher; | ||
import edu.umd.cs.findbugs.test.matcher.BugInstanceMatcherBuilder; | ||
import org.junit.jupiter.api.Test; | ||
|
||
import static edu.umd.cs.findbugs.test.CountMatcher.containsExactly; | ||
import static org.hamcrest.MatcherAssert.assertThat; | ||
import static org.hamcrest.Matchers.hasItem; | ||
|
||
class Bug3277814Test extends AbstractIntegrationTest { | ||
@Test | ||
void test() { | ||
performAnalysis("sfBugs/Bug3277814.class"); | ||
|
||
assertNoNpBugInMethod("test"); | ||
assertNpBugInMethod("test2", 44); | ||
} | ||
|
||
private void assertNoNpBugInMethod(String method) { | ||
final String[] bugtypes = new String[] { | ||
"NP_SYNC_AND_NULL_CHECK_FIELD", "NP_BOOLEAN_RETURN_NULL", "NP_OPTIONAL_RETURN_NULL", | ||
"NP_NONNULL_FIELD_NOT_INITIALIZED_IN_CONSTRUCTOR", "NP_ARGUMENT_MIGHT_BE_NULL", | ||
"NP_EQUALS_SHOULD_HANDLE_NULL_ARGUMENT", "NP_DEREFERENCE_OF_READLINE_VALUE", | ||
"NP_IMMEDIATE_DEREFERENCE_OF_READLINE", "NP_UNWRITTEN_FIELD", "NP_UNWRITTEN_PUBLIC_OR_PROTECTED_FIELD", | ||
"NP_ALWAYS_NULL", "NP_CLOSING_NULL", "NP_STORE_INTO_NONNULL_FIELD", "NP_ALWAYS_NULL_EXCEPTION", | ||
"NP_PARAMETER_MUST_BE_NONNULL_BUT_MARKED_AS_NULLABLE", "NP_NULL_ON_SOME_PATH_FROM_RETURN_VALUE", | ||
"NP_NULL_ON_SOME_PATH_MIGHT_BE_INFEASIBLE", "NP_NULL_ON_SOME_PATH", "NP_NULL_ON_SOME_PATH_EXCEPTION", | ||
"NP_NULL_PARAM_DEREF", "NP_NULL_PARAM_DEREF_NONVIRTUAL", "NP_NULL_PARAM_DEREF_ALL_TARGETS_DANGEROUS", | ||
"NP_NONNULL_PARAM_VIOLATION", "NP_NONNULL_RETURN_VIOLATION", "NP_TOSTRING_COULD_RETURN_NULL", | ||
"NP_CLONE_COULD_RETURN_NULL", "NP_LOAD_OF_KNOWN_NULL_VALUE", "NP_GUARANTEED_DEREF", | ||
"NP_GUARANTEED_DEREF_ON_EXCEPTION_PATH", "NP_NULL_INSTANCEOF", "BC_NULL_INSTANCEOF", | ||
"NP_METHOD_RETURN_RELAXING_ANNOTATION", "NP_METHOD_PARAMETER_TIGHTENS_ANNOTATION", | ||
"NP_METHOD_PARAMETER_RELAXING_ANNOTATION", | ||
}; | ||
for (String bugtype : bugtypes) { | ||
final BugInstanceMatcher bugInstanceMatcher = new BugInstanceMatcherBuilder() | ||
.bugType(bugtype) | ||
.inClass("Bug3277814") | ||
.inMethod(method) | ||
.build(); | ||
assertThat(getBugCollection(), containsExactly(0, bugInstanceMatcher)); | ||
} | ||
} | ||
|
||
private void assertNpBugInMethod(String method, int line) { | ||
final BugInstanceMatcher bugInstanceMatcher = new BugInstanceMatcherBuilder() | ||
.bugType("NP_NULL_ON_SOME_PATH") | ||
.inClass("Bug3277814") | ||
.inMethod(method) | ||
.atLine(line) | ||
.build(); | ||
assertThat(getBugCollection(), hasItem(bugInstanceMatcher)); | ||
} | ||
} |
30 changes: 30 additions & 0 deletions
30
spotbugs-tests/src/test/java/edu/umd/cs/findbugs/detect/RegressionIdeas2008091415Test.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
package edu.umd.cs.findbugs.detect; | ||
|
||
import edu.umd.cs.findbugs.AbstractIntegrationTest; | ||
import edu.umd.cs.findbugs.test.matcher.BugInstanceMatcher; | ||
import edu.umd.cs.findbugs.test.matcher.BugInstanceMatcherBuilder; | ||
import org.junit.jupiter.api.Test; | ||
|
||
import static edu.umd.cs.findbugs.test.CountMatcher.containsExactly; | ||
import static org.hamcrest.MatcherAssert.assertThat; | ||
|
||
class RegressionIdeas2008091415Test extends AbstractIntegrationTest { | ||
@Test | ||
void test() { | ||
performAnalysis("bugIdeas/Ideas_2008_09_14.class", "bugIdeas/Ideas_2008_09_15.class"); | ||
|
||
assertBugInMethod("Ideas_2008_09_14", "foo", 6); | ||
assertBugInMethod("Ideas_2008_09_15", "alternativesToInstanceof", 6); | ||
assertBugInMethod("Ideas_2008_09_15", "alternativesToInstanceofAndCheckedCast", 12); | ||
} | ||
|
||
private void assertBugInMethod(String className, String method, int line) { | ||
final BugInstanceMatcher bugInstanceMatcher = new BugInstanceMatcherBuilder() | ||
.bugType("BC_IMPOSSIBLE_CAST") | ||
.inClass(className) | ||
.inMethod(method) | ||
.atLine(line) | ||
.build(); | ||
assertThat(getBugCollection(), containsExactly(1, bugInstanceMatcher)); | ||
} | ||
} |
65 changes: 65 additions & 0 deletions
65
spotbugs-tests/src/test/java/edu/umd/cs/findbugs/detect/RegressionIdeas20111219Test.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
package edu.umd.cs.findbugs.detect; | ||
|
||
import edu.umd.cs.findbugs.AbstractIntegrationTest; | ||
import edu.umd.cs.findbugs.test.matcher.BugInstanceMatcher; | ||
import edu.umd.cs.findbugs.test.matcher.BugInstanceMatcherBuilder; | ||
import org.junit.jupiter.api.Test; | ||
|
||
import static edu.umd.cs.findbugs.test.CountMatcher.containsExactly; | ||
import static org.hamcrest.MatcherAssert.assertThat; | ||
import static org.hamcrest.Matchers.hasItem; | ||
|
||
class RegressionIdeas20111219Test extends AbstractIntegrationTest { | ||
@Test | ||
void test() { | ||
performAnalysis("bugIdeas/Ideas_2011_12_19.class"); | ||
|
||
assertNoNpBugInMethod("f"); | ||
assertBugInMethod("NP_ALWAYS_NULL", "f2", 21); | ||
assertBugInMethod("NP_LOAD_OF_KNOWN_NULL_VALUE", "f2", 21); | ||
assertNoNpBugInMethod("f3"); | ||
assertNoNpBugInMethod("f4"); | ||
assertBugInMethod("NP_NULL_ON_SOME_PATH_FROM_RETURN_VALUE", "f5a", 48); | ||
assertNoNpBugInMethod("f5b"); | ||
assertNoNpBugInMethod("f5c"); | ||
assertNoNpBugInMethod("f5e"); | ||
assertNoNpBugInMethod("f5f"); | ||
assertBugInMethod("NP_NULL_ON_SOME_PATH", "f5g", 81); | ||
} | ||
|
||
private void assertNoNpBugInMethod(String method) { | ||
final String[] bugtypes = new String[] { | ||
"NP_SYNC_AND_NULL_CHECK_FIELD", "NP_BOOLEAN_RETURN_NULL", "NP_OPTIONAL_RETURN_NULL", | ||
"NP_NONNULL_FIELD_NOT_INITIALIZED_IN_CONSTRUCTOR", "NP_ARGUMENT_MIGHT_BE_NULL", | ||
"NP_EQUALS_SHOULD_HANDLE_NULL_ARGUMENT", "NP_DEREFERENCE_OF_READLINE_VALUE", | ||
"NP_IMMEDIATE_DEREFERENCE_OF_READLINE", "NP_UNWRITTEN_FIELD", "NP_UNWRITTEN_PUBLIC_OR_PROTECTED_FIELD", | ||
"NP_ALWAYS_NULL", "NP_CLOSING_NULL", "NP_STORE_INTO_NONNULL_FIELD", "NP_ALWAYS_NULL_EXCEPTION", | ||
"NP_PARAMETER_MUST_BE_NONNULL_BUT_MARKED_AS_NULLABLE", "NP_NULL_ON_SOME_PATH_FROM_RETURN_VALUE", | ||
"NP_NULL_ON_SOME_PATH_MIGHT_BE_INFEASIBLE", "NP_NULL_ON_SOME_PATH", "NP_NULL_ON_SOME_PATH_EXCEPTION", | ||
"NP_NULL_PARAM_DEREF", "NP_NULL_PARAM_DEREF_NONVIRTUAL", "NP_NULL_PARAM_DEREF_ALL_TARGETS_DANGEROUS", | ||
"NP_NONNULL_PARAM_VIOLATION", "NP_NONNULL_RETURN_VIOLATION", "NP_TOSTRING_COULD_RETURN_NULL", | ||
"NP_CLONE_COULD_RETURN_NULL", "NP_LOAD_OF_KNOWN_NULL_VALUE", "NP_GUARANTEED_DEREF", | ||
"NP_GUARANTEED_DEREF_ON_EXCEPTION_PATH", "NP_NULL_INSTANCEOF", "BC_NULL_INSTANCEOF", | ||
"NP_METHOD_RETURN_RELAXING_ANNOTATION", "NP_METHOD_PARAMETER_TIGHTENS_ANNOTATION", | ||
"NP_METHOD_PARAMETER_RELAXING_ANNOTATION", | ||
}; | ||
for (String bugtype : bugtypes) { | ||
final BugInstanceMatcher bugInstanceMatcher = new BugInstanceMatcherBuilder() | ||
.bugType(bugtype) | ||
.inClass("Bug3277814") | ||
.inMethod(method) | ||
.build(); | ||
assertThat(getBugCollection(), containsExactly(0, bugInstanceMatcher)); | ||
} | ||
} | ||
|
||
private void assertBugInMethod(String bugtype, String method, int line) { | ||
final BugInstanceMatcher bugInstanceMatcher = new BugInstanceMatcherBuilder() | ||
.bugType(bugtype) | ||
.inClass("Ideas_2011_12_19") | ||
.inMethod(method) | ||
.atLine(line) | ||
.build(); | ||
assertThat(getBugCollection(), hasItem(bugInstanceMatcher)); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.