-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Expand file tree
/
Copy pathDuplicateDependency.ql
More file actions
30 lines (27 loc) · 991 Bytes
/
DuplicateDependency.ql
File metadata and controls
30 lines (27 loc) · 991 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 Duplicate dependency
* @description Repeated dependency names are redundant for AngularJS dependency injection.
* @kind problem
* @problem.severity warning
* @precision very-high
* @id js/angular/duplicate-dependency
* @tags quality
* maintainability
* readability
* frameworks/angularjs
*/
import javascript
import semmle.javascript.RestrictedLocations
predicate isRepeatedDependency(AngularJS::InjectableFunction f, string name, DataFlow::Node node) {
exists(int i, int j |
i < j and
exists(f.getDependencyDeclaration(i, name)) and
node = f.getDependencyDeclaration(j, name)
)
}
from AngularJS::InjectableFunction f, DataFlow::Node node, string name
where
isRepeatedDependency(f, name, node) and
not count(f.asFunction().getParameterByName(name)) > 1 // avoid duplicating reports from js/duplicate-parameter-name
select f.asFunction().getFunction().(FirstLineOf), "This function has a duplicate dependency $@.",
node, name