Skip to content

Commit 0ebf53b

Browse files
authored
Merge pull request github#6073 from geoffw0/loc
C++: Add lines of user code query
2 parents cce8eac + d7db182 commit 0ebf53b

File tree

5 files changed

+32
-1
lines changed

5 files changed

+32
-1
lines changed

cpp/ql/src/Summary/LinesOfUserCode.ql

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
/**
2+
* @name Total lines of user written C/C++ code in the database
3+
* @description The total number of lines of C/C++ code from the source code directory, excluding auto-generated files. This query counts the lines of code, excluding whitespace or comments. Note: If external libraries are included in the codebase either in a checked-in virtual environment or as vendored code, that will currently be counted as user written code.
4+
* @kind metric
5+
* @tags summary
6+
* lines-of-code
7+
* @id cpp/summary/lines-of-user-code
8+
*/
9+
10+
import cpp
11+
import semmle.code.cpp.AutogeneratedFile
12+
13+
select sum(File f |
14+
f.fromSource() and exists(f.getRelativePath()) and not f instanceof AutogeneratedFile
15+
|
16+
f.getMetrics().getNumberOfLinesOfCode()
17+
)
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
| 93 |
1+
| 96 |
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
| 93 |
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Summary/LinesOfUserCode.ql
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
/**
2+
* This file is generated by abc.xyz. Do not edit!
3+
*
4+
* (except that this isn't really a generated file, but the above is the typical sort of comment
5+
* you see at the beginning of a true generated file).
6+
*/
7+
8+
int generated_function() {
9+
// ...
10+
11+
return 1;
12+
}

0 commit comments

Comments
 (0)