mirror of
https://github.com/github/codeql.git
synced 2026-01-20 18:04:46 +01:00
Some files that will change in #1736 have been spared. ./build -j4 target/jars/qlformat find ql/cpp/ql -name "*.ql" -print0 | xargs -0 target/jars/qlformat --input find ql/cpp/ql -name "*.qll" -print0 | xargs -0 target/jars/qlformat --input (cd ql && git checkout 'cpp/ql/src/semmle/code/cpp/ir/implementation/**/*SSA*.qll') buildutils-internal/scripts/pr-checks/sync-identical-files.py --latest
39 lines
954 B
Plaintext
39 lines
954 B
Plaintext
/**
|
|
* @name Number of distinct conditions used in #if, #ifdef, #ifndef etc. per file
|
|
* @description For each file, the number of unique conditions used by
|
|
* `#if`, `#ifdef`, and `#ifndef`.
|
|
* @kind treemap
|
|
* @id cpp/conditional-segment-conditions
|
|
* @treemap.warnOn highValues
|
|
* @metricType file
|
|
* @metricAggregate avg max
|
|
* @tags maintainability
|
|
* readability
|
|
*/
|
|
|
|
import cpp
|
|
|
|
predicate preprocessorOpenCondition(PreprocessorDirective d) {
|
|
d instanceof PreprocessorIf or
|
|
d instanceof PreprocessorIfdef or
|
|
d instanceof PreprocessorIfndef
|
|
}
|
|
|
|
predicate headerGuard(PreprocessorIfndef notdef) {
|
|
notdef.getHead().regexpMatch(".*_H_.*")
|
|
or
|
|
notdef.getHead().regexpMatch(".*_H")
|
|
}
|
|
|
|
from File f
|
|
where f.fromSource()
|
|
select f,
|
|
count(string s |
|
|
exists(PreprocessorDirective open |
|
|
preprocessorOpenCondition(open) and
|
|
not headerGuard(open) and
|
|
open.getFile() = f and
|
|
s = open.getHead()
|
|
)
|
|
)
|