forked from github/codeql
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDependencyMismatch.ql
More file actions
30 lines (28 loc) · 996 Bytes
/
DependencyMismatch.ql
File metadata and controls
30 lines (28 loc) · 996 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
30
/**
* @name Dependency mismatch
* @description If the injected dependencies of a function go out of sync
* with its parameters, the function will become difficult to
* understand and maintain.
* @kind problem
* @problem.severity warning
* @precision very-high
* @id js/angular/dependency-injection-mismatch
* @tags correctness
* maintainability
* frameworks/angularjs
*/
import javascript
from AngularJS::InjectableFunction f, SimpleParameter p, string msg
where p = f.asFunction().getAParameter() and
(
not p = f.getDependencyParameter(_) and
msg = "This parameter has no injected dependency."
or
exists (string n | p = f.getDependencyParameter(n) |
p.getName() != n and
exists(f.getDependencyParameter(p.getName())) and
msg = "This parameter is named '" + p.getName() + "', " +
"but actually refers to dependency '" + n + "'."
)
)
select p, msg