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 1
1
private import codeql.swift.generated.File
2
+ private import codeql.swift.elements.Location
3
+ private import codeql.swift.elements.UnknownLocation
2
4
3
5
class File extends Generated:: File {
4
6
/** toString */
@@ -17,4 +19,17 @@ class File extends Generated::File {
17
19
string getBaseName ( ) {
18
20
result = this .getAbsolutePath ( ) .regexpCapture ( ".*/(([^/]*?)(?:\\.([^.]*))?)" , 1 )
19
21
}
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
+ }
20
35
}
Original file line number Diff line number Diff line change 8
8
9
9
import swift
10
10
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
12
12
import codeql.swift.dataflow.DataFlow
13
13
import codeql.swift.dataflow.TaintTracking
14
14
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
-
24
15
/**
25
16
* A taint configuration for tainted data reaching any node.
26
17
*/
@@ -46,7 +37,7 @@ float taintReach() { result = (taintedNodesCount() * 1000000.0) / count(DataFlow
46
37
predicate statistic ( string what , string value ) {
47
38
what = "Files" and value = count ( File f ) .toString ( )
48
39
or
49
- what = "Lines of code" and value = linesOfCode ( ) .toString ( )
40
+ what = "Lines of code" and value = sum ( File f | | f . getNumberOfLinesOfCode ( ) ) .toString ( )
50
41
or
51
42
what = "Compiler errors" and value = count ( CompilerError d ) .toString ( )
52
43
or
You can’t perform that action at this time.
0 commit comments