mirror of
https://github.com/github/codeql.git
synced 2026-04-26 17:25:19 +02:00
Make query more accepting
This commit is contained in:
@@ -65,16 +65,6 @@ class SurefireTest extends Class {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Frameworks that provide `PointCuts`
|
||||
* which commonly intentionally annotate empty methods
|
||||
*/
|
||||
class PointCutAnnotation extends Annotation {
|
||||
PointCutAnnotation() {
|
||||
this.getType().hasQualifiedName("org.aspectj.lang.annotation", "Pointcut")
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* A `Method` from source that is not abstract
|
||||
*/
|
||||
@@ -94,6 +84,10 @@ where
|
||||
m.getNumberOfCommentLines() = 0 and
|
||||
//permit a javadoc above as well as sufficient reason to leave empty
|
||||
not exists(Javadoc jd | m.getDoc().getJavadoc() = jd) and
|
||||
//methods annotated this way are usually intentionally empty
|
||||
not exists(PointCutAnnotation a | a = m.getAnAnnotation())
|
||||
//annotated methods are considered compliant
|
||||
not exists(m.getAnAnnotation()) and
|
||||
//default methods are not abstract, but are considered compliant
|
||||
not m.isDefault() and
|
||||
//native methods have no body
|
||||
not m.isNative()
|
||||
select m, "Empty method found."
|
||||
|
||||
@@ -1,3 +1 @@
|
||||
| Test.java:13:15:13:16 | f2 | Empty method found. |
|
||||
| Test.java:27:17:27:17 | f | Empty method found. |
|
||||
| Test.java:32:18:32:23 | method | Empty method found. |
|
||||
|
||||
@@ -24,12 +24,16 @@ public class Test {
|
||||
public class Derived extends TestInner {
|
||||
|
||||
@Override
|
||||
public void f() { } // $ Alert
|
||||
public void f() {
|
||||
}
|
||||
|
||||
public native int nativeMethod();
|
||||
}
|
||||
|
||||
public interface TestInterface {
|
||||
|
||||
default void method() { } // $ Alert
|
||||
default void method() {
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user