File tree Expand file tree Collapse file tree 4 files changed +40
-5
lines changed
lib/codeql/swift/elements Expand file tree Collapse file tree 4 files changed +40
-5
lines changed Original file line number Diff line number Diff line change 11private import codeql.swift.generated.Diagnostics
22
3+ /**
4+ * A compiler-generated error, warning, note or remark.
5+ */
36class Diagnostics extends Generated:: Diagnostics {
47 override string toString ( ) { result = this .getSeverity ( ) + ": " + this .getText ( ) }
58
9+ /**
10+ * Gets a string representing the severity of this compiler diagnostic.
11+ */
612 string getSeverity ( ) {
713 this .getKind ( ) = 1 and result = "error"
814 or
@@ -14,18 +20,30 @@ class Diagnostics extends Generated::Diagnostics {
1420 }
1521}
1622
23+ /**
24+ * A compiler error message.
25+ */
1726class CompilerError extends Diagnostics {
1827 CompilerError ( ) { this .getSeverity ( ) = "error" }
1928}
2029
30+ /**
31+ * A compiler-generated warning.
32+ */
2133class CompilerWarning extends Diagnostics {
2234 CompilerWarning ( ) { this .getSeverity ( ) = "warning" }
2335}
2436
37+ /**
38+ * A compiler-generated note (typically attached to an error or warning).
39+ */
2540class CompilerNote extends Diagnostics {
2641 CompilerNote ( ) { this .getSeverity ( ) = "note" }
2742}
2843
44+ /**
45+ * A compiler-generated remark (milder than a warning, this does not indicate an issue).
46+ */
2947class CompilerRemark extends Diagnostics {
3048 CompilerRemark ( ) { this .getSeverity ( ) = "remark" }
3149}
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 @@ -37,6 +37,12 @@ float taintReach() { result = (taintedNodesCount() * 1000000.0) / count(DataFlow
3737predicate statistic ( string what , string value ) {
3838 what = "Files" and value = count ( File f ) .toString ( )
3939 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
4046 what = "Expressions" and value = count ( Expr e | not e .getFile ( ) instanceof UnknownFile ) .toString ( )
4147 or
4248 what = "Local flow sources" and value = count ( LocalFlowSource s ) .toString ( )
You can’t perform that action at this time.
0 commit comments