mirror of
https://github.com/github/codeql.git
synced 2025-12-18 01:33:15 +01:00
QL: Add query for outdated deprecations
This commit is contained in:
24
ql/ql/src/queries/reports/OutdatedDeprecations.ql
Normal file
24
ql/ql/src/queries/reports/OutdatedDeprecations.ql
Normal file
@@ -0,0 +1,24 @@
|
|||||||
|
import ql
|
||||||
|
import codeql_ql.ast.internal.TreeSitter
|
||||||
|
|
||||||
|
date today() { result = any(Blame::BlameInfo b).getToday().getValue().toDate() }
|
||||||
|
|
||||||
|
class DatedDeprecation extends Annotation {
|
||||||
|
date lastModified;
|
||||||
|
|
||||||
|
DatedDeprecation() {
|
||||||
|
this.getName() = "deprecated" and
|
||||||
|
exists(Blame::FileEntry f, Blame::BlameEntry b |
|
||||||
|
f.getFileName().getValue() = this.getLocation().getFile().getRelativePath() and
|
||||||
|
f.getBlameEntry(_) = b and
|
||||||
|
b.getLine(_).getValue().toInt() = this.getLocation().getStartLine() and
|
||||||
|
lastModified = b.getDate().getValue().toDate()
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
date getLastModified() { result = lastModified }
|
||||||
|
}
|
||||||
|
|
||||||
|
from DatedDeprecation d
|
||||||
|
where d.getLastModified().daysTo(today()) > 365
|
||||||
|
select d, "This deprecation is over a year old."
|
||||||
Reference in New Issue
Block a user