Skip to content

Commit dc7a286

Browse files
committed
Swift: Add lines of code to SummaryStats.ql.
1 parent 93215ba commit dc7a286

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

swift/ql/src/queries/Summary/SummaryStats.ql

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,15 @@ import codeql.swift.security.SensitiveExprs
1212
import codeql.swift.dataflow.DataFlow
1313
import codeql.swift.dataflow.TaintTracking
1414

15+
int linesOfCode() {
16+
// approximate number of lines of code in the database
17+
result = count(File f, int line |
18+
exists(Location loc |
19+
not loc instanceof UnknownLocation and loc.getFile() = f and loc.getStartLine() = line
20+
)
21+
)
22+
}
23+
1524
/**
1625
* A taint configuration for tainted data reaching any node.
1726
*/
@@ -37,6 +46,8 @@ float taintReach() { result = (taintedNodesCount() * 1000000.0) / count(DataFlow
3746
predicate statistic(string what, string value) {
3847
what = "Files" and value = count(File f).toString()
3948
or
49+
what = "Lines of code" and value = linesOfCode().toString()
50+
or
4051
what = "Expressions" and value = count(Expr e | not e.getFile() instanceof UnknownFile).toString()
4152
or
4253
what = "Local flow sources" and value = count(LocalFlowSource s).toString()

0 commit comments

Comments
 (0)