mirror of
https://github.com/github/codeql.git
synced 2025-12-28 14:46:33 +01:00
33 lines
968 B
Plaintext
33 lines
968 B
Plaintext
/**
|
|
* @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, 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
|