mirror of
https://github.com/github/codeql.git
synced 2026-04-28 02:05:14 +02:00
Merge pull request #5744 from tamasvajk/feature/java-loc
Java: Introduce LoC summary metric query
This commit is contained in:
13
java/ql/src/Metrics/Summaries/LinesOfCode.ql
Normal file
13
java/ql/src/Metrics/Summaries/LinesOfCode.ql
Normal file
@@ -0,0 +1,13 @@
|
||||
/**
|
||||
* @id java/summary/lines-of-code
|
||||
* @name Total lines of code in the database
|
||||
* @description The total number of lines of code across all files. This is a useful metric of the size of a database.
|
||||
* For all files that were seen during the build, this query counts the lines of code, excluding whitespace
|
||||
* or comments.
|
||||
* @kind metric
|
||||
* @tags summary
|
||||
*/
|
||||
|
||||
import java
|
||||
|
||||
select sum(CompilationUnit f | f.fromSource() | f.getNumberOfLinesOfCode())
|
||||
9
java/ql/test/query-tests/Metrics/A.java
Normal file
9
java/ql/test/query-tests/Metrics/A.java
Normal file
@@ -0,0 +1,9 @@
|
||||
public class A {
|
||||
public void M() {
|
||||
//some comment
|
||||
}
|
||||
|
||||
/* public void M() {
|
||||
//some comment
|
||||
} */
|
||||
}
|
||||
1
java/ql/test/query-tests/Metrics/LinesOfCode.expected
Normal file
1
java/ql/test/query-tests/Metrics/LinesOfCode.expected
Normal file
@@ -0,0 +1 @@
|
||||
| 4 |
|
||||
1
java/ql/test/query-tests/Metrics/LinesOfCode.qlref
Normal file
1
java/ql/test/query-tests/Metrics/LinesOfCode.qlref
Normal file
@@ -0,0 +1 @@
|
||||
Metrics/Summaries/LinesOfCode.ql
|
||||
Reference in New Issue
Block a user