forked from github/codeql
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathFTransitiveSourceIncludes.ql
More file actions
30 lines (27 loc) · 883 Bytes
/
FTransitiveSourceIncludes.ql
File metadata and controls
30 lines (27 loc) · 883 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 Indirect source includes per file
* @description The number of source files included by the
* pre-processor - either directly by an `#include`
* directive, or indirectly (by being included by an
* included file). This metric excludes included files
* that aren't part of the main code base (like system
* headers).
* @kind treemap
* @id cpp/transitive-source-includes-per-file
* @treemap.warnOn highValues
* @metricType file
* @metricAggregate avg max
* @tags maintainability
* modularity
*/
import cpp
predicate isInCodebase(File f) {
exists(string prefix | sourceLocationPrefix(prefix) |
f.getAbsolutePath().prefix(prefix.length()) = prefix
)
}
from File f, int n
where
f.fromSource() and
n = count(File g | g = f.getAnIncludedFile+() and isInCodebase(g))
select f, n