File tree 4 files changed +40
-5
lines changed
lib/codeql/swift/elements
4 files changed +40
-5
lines changed Original file line number Diff line number Diff line change 1
1
private import codeql.swift.generated.Diagnostics
2
2
3
+ /**
4
+ * A compiler-generated error, warning, note or remark.
5
+ */
3
6
class Diagnostics extends Generated:: Diagnostics {
4
7
override string toString ( ) { result = this .getSeverity ( ) + ": " + this .getText ( ) }
5
8
9
+ /**
10
+ * Gets a string representing the severity of this compiler diagnostic.
11
+ */
6
12
string getSeverity ( ) {
7
13
this .getKind ( ) = 1 and result = "error"
8
14
or
@@ -14,18 +20,30 @@ class Diagnostics extends Generated::Diagnostics {
14
20
}
15
21
}
16
22
23
+ /**
24
+ * A compiler error message.
25
+ */
17
26
class CompilerError extends Diagnostics {
18
27
CompilerError ( ) { this .getSeverity ( ) = "error" }
19
28
}
20
29
30
+ /**
31
+ * A compiler-generated warning.
32
+ */
21
33
class CompilerWarning extends Diagnostics {
22
34
CompilerWarning ( ) { this .getSeverity ( ) = "warning" }
23
35
}
24
36
37
+ /**
38
+ * A compiler-generated note (typically attached to an error or warning).
39
+ */
25
40
class CompilerNote extends Diagnostics {
26
41
CompilerNote ( ) { this .getSeverity ( ) = "note" }
27
42
}
28
43
44
+ /**
45
+ * A compiler-generated remark (milder than a warning, this does not indicate an issue).
46
+ */
29
47
class CompilerRemark extends Diagnostics {
30
48
CompilerRemark ( ) { this .getSeverity ( ) = "remark" }
31
49
}
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 @@ -37,6 +37,12 @@ float taintReach() { result = (taintedNodesCount() * 1000000.0) / count(DataFlow
37
37
predicate statistic ( string what , string value ) {
38
38
what = "Files" and value = count ( File f ) .toString ( )
39
39
or
40
+ what = "Lines of code" and value = sum ( File f | | f .getNumberOfLinesOfCode ( ) ) .toString ( )
41
+ or
42
+ what = "Compiler errors" and value = count ( CompilerError d ) .toString ( )
43
+ or
44
+ what = "Compiler warnings" and value = count ( CompilerWarning d ) .toString ( )
45
+ or
40
46
what = "Expressions" and value = count ( Expr e | not e .getFile ( ) instanceof UnknownFile ) .toString ( )
41
47
or
42
48
what = "Local flow sources" and value = count ( LocalFlowSource s ) .toString ( )
You can’t perform that action at this time.
0 commit comments