mirror of
https://github.com/github/codeql.git
synced 2025-12-16 16:53:25 +01:00
QL4QL: Remove MissingOverride query
This commit is contained in:
@@ -1,20 +0,0 @@
|
||||
/**
|
||||
* @name Missing override annotation
|
||||
* @description Predicates that override another predicate should have an `override` annotation.
|
||||
* @kind problem
|
||||
* @problem.severity warning
|
||||
* @precision very-high
|
||||
* @id ql/missing-override
|
||||
* @tags maintainability
|
||||
*/
|
||||
|
||||
import ql
|
||||
|
||||
string getQualifiedName(ClassPredicate p) {
|
||||
result = p.getDeclaringType().getName() + "." + p.getName()
|
||||
}
|
||||
|
||||
from ClassPredicate pred, ClassPredicate sup
|
||||
where pred.overrides(sup) and not pred.isOverride()
|
||||
select pred, getQualifiedName(pred) + " overrides $@ but does not have an override annotation.",
|
||||
sup, getQualifiedName(sup)
|
||||
@@ -1,2 +0,0 @@
|
||||
| Test.qll:12:13:12:16 | ClassPredicate test | Wrong.test overrides $@ but does not have an override annotation. | Test.qll:4:13:4:16 | ClassPredicate test | Super.test |
|
||||
| Test.qll:18:13:18:16 | ClassPredicate test | Wrong2.test overrides $@ but does not have an override annotation. | Test.qll:4:13:4:16 | ClassPredicate test | Super.test |
|
||||
@@ -1 +0,0 @@
|
||||
queries/style/MissingOverride.ql
|
||||
@@ -1,37 +0,0 @@
|
||||
import ql
|
||||
|
||||
class Super extends AstNode {
|
||||
predicate test(int i) { i = [1 .. 5] }
|
||||
}
|
||||
|
||||
class Correct extends Super {
|
||||
override predicate test(int i) { i = 3 }
|
||||
}
|
||||
|
||||
class Wrong extends Super {
|
||||
predicate test(int i) { i = 2 }
|
||||
}
|
||||
|
||||
class Mid extends Super { }
|
||||
|
||||
class Wrong2 extends Mid {
|
||||
predicate test(int i) { i = 2 }
|
||||
}
|
||||
|
||||
final class SuperFinal = Super;
|
||||
|
||||
class Correct2 extends SuperFinal {
|
||||
predicate test(int i) { i = 4 }
|
||||
}
|
||||
|
||||
class Correct3 extends AstNode instanceof SuperFinal {
|
||||
predicate test(int i) { i = 4 }
|
||||
}
|
||||
|
||||
final class Super2 extends AstNode {
|
||||
predicate test(int i) { i = [1 .. 5] }
|
||||
}
|
||||
|
||||
class Correct4 extends Super2 {
|
||||
predicate test(int i) { i = 3 }
|
||||
}
|
||||
Reference in New Issue
Block a user