-
Notifications
You must be signed in to change notification settings - Fork 2k
Expand file tree
/
Copy pathDependencyMismatch.ql
More file actions
33 lines (31 loc) · 981 Bytes
/
DependencyMismatch.ql
File metadata and controls
33 lines (31 loc) · 981 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
31
32
33
/**
* @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 quality
* reliability
* correctness
* frameworks/angularjs
*/
import javascript
from AngularJS::InjectableFunction f, DataFlow::ParameterNode 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