QL: Add query for outdated deprecations

This commit is contained in:
Taus
2023-02-17 13:22:48 +00:00
parent db748fae6b
commit 9f4f7a76c9

View 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."