mirror of
https://github.com/github/codeql.git
synced 2026-04-24 00:05:14 +02:00
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:
@@ -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)
|
||||
|
||||
@@ -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. |
|
||||
|
||||
Reference in New Issue
Block a user