Ignore types with methods which have annotations

The motivation is test classes in JUnit 4 and 5 are currently FPs for this. They have methods with `@Test`, so this should fix the FPs.
This commit is contained in:
Owen Mansel-Chan
2024-06-14 12:26:58 +01:00
parent 050dcb1370
commit cd0af0fc57
2 changed files with 1 additions and 1 deletions

View File

@@ -49,6 +49,7 @@ predicate dead(RefType dead) {
not dead instanceof AnonymousClass and
// Exclude classes that look like they may be reflectively constructed.
not dead.getAnAnnotation() instanceof ReflectiveAccessAnnotation and
not dead.getAMethod().getAnAnnotation() instanceof ReflectiveAccessAnnotation and
// Insist all source ancestors are dead as well.
forall(RefType t | t.fromSource() and t = getASuperTypePlus(dead) | dead(t)) and
// Exclude compiler generated classes (e.g. declaring type of adapter functions in Kotlin)

View File

@@ -1,2 +1 @@
| ClassWithAnnotatedMethod.java:1:7:1:30 | ClassWithAnnotatedMethod | Unused class: ClassWithAnnotatedMethod is not referenced within this codebase. If not used as an external API it should be removed. |
| UnusedClass.java:1:7:1:17 | UnusedClass | Unused class: UnusedClass is not referenced within this codebase. If not used as an external API it should be removed. |