Skip to content

Commit 9f4f7a7

Browse files
committed
QL: Add query for outdated deprecations
1 parent db748fa commit 9f4f7a7

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+
import ql
2+
import codeql_ql.ast.internal.TreeSitter
3+
4+
date today() { result = any(Blame::BlameInfo b).getToday().getValue().toDate() }
5+
6+
class DatedDeprecation extends Annotation {
7+
date lastModified;
8+
9+
DatedDeprecation() {
10+
this.getName() = "deprecated" and
11+
exists(Blame::FileEntry f, Blame::BlameEntry b |
12+
f.getFileName().getValue() = this.getLocation().getFile().getRelativePath() and
13+
f.getBlameEntry(_) = b and
14+
b.getLine(_).getValue().toInt() = this.getLocation().getStartLine() and
15+
lastModified = b.getDate().getValue().toDate()
16+
)
17+
}
18+
19+
date getLastModified() { result = lastModified }
20+
}
21+
22+
from DatedDeprecation d
23+
where d.getLastModified().daysTo(today()) > 365
24+
select d, "This deprecation is over a year old."

0 commit comments

Comments
 (0)