forked from github/codeql
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathFSelfContainedness.ql
More file actions
32 lines (30 loc) · 1.08 KB
/
FSelfContainedness.ql
File metadata and controls
32 lines (30 loc) · 1.08 KB
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
/**
* @name Self-containedness of files
* @description The percentage of the types on which a compilation unit depends for which we have the source code.
* @kind treemap
* @treemap.warnOn lowValues
* @metricType file
* @metricAggregate avg max
* @id java/source-dependency-ratio-per-file
* @tags portability
* modularity
*/
import java
from CompilationUnit f, float selfContaindness, int efferentSourceCoupling, int efferentCoupling
where
efferentSourceCoupling =
count(CompilationUnit g |
exists(RefType c | c.fromSource() and c.getCompilationUnit() = g |
exists(RefType d | d.fromSource() and d.getCompilationUnit() = f | depends(d, c))
)
) and
efferentCoupling =
count(CompilationUnit g |
exists(RefType c | c.getCompilationUnit() = g |
exists(RefType d | d.fromSource() and d.getCompilationUnit() = f | depends(d, c))
)
) and
if efferentCoupling = 0
then selfContaindness = 100
else selfContaindness = 100 * efferentSourceCoupling.(float) / efferentCoupling
select f, selfContaindness order by selfContaindness desc