File tree Expand file tree Collapse file tree 3 files changed +17
-15
lines changed
lib/codeql/swift/elements Expand file tree Collapse file tree 3 files changed +17
-15
lines changed Original file line number Diff line number Diff line change 11private import codeql.swift.generated.File
2+ private import codeql.swift.elements.Location
3+ private import codeql.swift.elements.UnknownLocation
24
35class File extends Generated:: File {
46 /** toString */
@@ -17,4 +19,17 @@ class File extends Generated::File {
1719 string getBaseName ( ) {
1820 result = this .getAbsolutePath ( ) .regexpCapture ( ".*/(([^/]*?)(?:\\.([^.]*))?)" , 1 )
1921 }
22+
23+ /**
24+ * Gets the number of lines containing code in this file. This value
25+ * is approximate.
26+ */
27+ int getNumberOfLinesOfCode ( ) {
28+ result =
29+ count ( int line |
30+ exists ( Location loc |
31+ not loc instanceof UnknownLocation and loc .getFile ( ) = this and loc .getStartLine ( ) = line
32+ )
33+ )
34+ }
2035}
Original file line number Diff line number Diff line change 88
99import swift
1010
11- select count ( File f , int line |
12- exists ( Location loc |
13- not loc instanceof UnknownLocation and loc .getFile ( ) = f and loc .getStartLine ( ) = line
14- )
15- )
11+ select sum ( File f | | f .getNumberOfLinesOfCode ( ) )
Original file line number Diff line number Diff line change @@ -12,15 +12,6 @@ import codeql.swift.security.SensitiveExprs
1212import codeql.swift.dataflow.DataFlow
1313import 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-
2415/**
2516 * A taint configuration for tainted data reaching any node.
2617 */
@@ -46,7 +37,7 @@ float taintReach() { result = (taintedNodesCount() * 1000000.0) / count(DataFlow
4637predicate statistic ( string what , string value ) {
4738 what = "Files" and value = count ( File f ) .toString ( )
4839 or
49- what = "Lines of code" and value = linesOfCode ( ) .toString ( )
40+ what = "Lines of code" and value = sum ( File f | | f . getNumberOfLinesOfCode ( ) ) .toString ( )
5041 or
5142 what = "Compiler errors" and value = count ( CompilerError d ) .toString ( )
5243 or
You can’t perform that action at this time.
0 commit comments