forked from github/codeql
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathAvoidDeprecatedCallableAccess.ql
More file actions
29 lines (26 loc) · 955 Bytes
/
AvoidDeprecatedCallableAccess.ql
File metadata and controls
29 lines (26 loc) · 955 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
/**
* @name Deprecated method or constructor invocation
* @description Using a method or constructor that has been marked as deprecated may be dangerous or
* fail to take advantage of a better method or constructor.
* @kind problem
* @problem.severity recommendation
* @precision high
* @id java/deprecated-call
* @tags maintainability
* readability
* non-attributable
* external/cwe/cwe-477
*/
import java
private predicate isDeprecatedCallable(Callable c) {
c.getAnAnnotation() instanceof DeprecatedAnnotation or
exists(c.getDoc().getJavadoc().getATag("@deprecated"))
}
from Call ca, Callable c
where
ca.getCallee().getSourceDeclaration() = c and
isDeprecatedCallable(c) and
// Exclude deprecated calls from within deprecated code.
not isDeprecatedCallable(ca.getCaller())
select ca, "Invoking $@ should be avoided because it has been deprecated.", c,
c.getDeclaringType() + "." + c.getName()