mirror of
https://github.com/github/codeql.git
synced 2026-04-27 01:35:13 +02:00
Merge pull request #8351 from erik-krogh/inconsistentDep
QL: add query detecting inconsistent deprecations
This commit is contained in:
24
ql/ql/src/queries/bugs/InconsistentDeprecation.ql
Normal file
24
ql/ql/src/queries/bugs/InconsistentDeprecation.ql
Normal file
@@ -0,0 +1,24 @@
|
||||
/**
|
||||
* @name Inconsistent deprecation
|
||||
* @description A deprecated predicate that overrides a non-deprecated predicate is an indication that the super-predicate should be deprecated.
|
||||
* @kind problem
|
||||
* @problem.severity warning
|
||||
* @id ql/inconsistent-deprecation
|
||||
* @tags correctness
|
||||
* maintanability
|
||||
* @precision very-high
|
||||
*/
|
||||
|
||||
import ql
|
||||
|
||||
predicate overrides(ClassPredicate sub, ClassPredicate sup, string description, string overrides) {
|
||||
sub.overrides(sup) and description = "predicate" and overrides = "predicate"
|
||||
}
|
||||
|
||||
from AstNode sub, AstNode sup, string description, string overrides
|
||||
where
|
||||
overrides(sub, sup, description, overrides) and
|
||||
sub.hasAnnotation("deprecated") and
|
||||
not sup.hasAnnotation("deprecated")
|
||||
select sub, "This deprecated " + description + " overrides $@. Consider deprecating both.", sup,
|
||||
"a non-deprecated " + overrides
|
||||
Reference in New Issue
Block a user