Skip to content

Commit 5cbe01d

Browse files
authored
Merge pull request #8351 from erik-krogh/inconsistentDep
QL: add query detecting inconsistent deprecations
2 parents e092cb0 + 8c6022b commit 5cbe01d

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
/**
2+
* @name Inconsistent deprecation
3+
* @description A deprecated predicate that overrides a non-deprecated predicate is an indication that the super-predicate should be deprecated.
4+
* @kind problem
5+
* @problem.severity warning
6+
* @id ql/inconsistent-deprecation
7+
* @tags correctness
8+
* maintanability
9+
* @precision very-high
10+
*/
11+
12+
import ql
13+
14+
predicate overrides(ClassPredicate sub, ClassPredicate sup, string description, string overrides) {
15+
sub.overrides(sup) and description = "predicate" and overrides = "predicate"
16+
}
17+
18+
from AstNode sub, AstNode sup, string description, string overrides
19+
where
20+
overrides(sub, sup, description, overrides) and
21+
sub.hasAnnotation("deprecated") and
22+
not sup.hasAnnotation("deprecated")
23+
select sub, "This deprecated " + description + " overrides $@. Consider deprecating both.", sup,
24+
"a non-deprecated " + overrides

0 commit comments

Comments
 (0)