From 13a9e83e6ad06051371cb392b8ed7d5f8ec7c83b Mon Sep 17 00:00:00 2001 From: Ian Lynagh Date: Fri, 20 Oct 2023 11:42:52 +0100 Subject: [PATCH 1/3] Java/Kotlin: Reshuffle our LoC queries There's now a single lines-of-code query that gives the total number of lines of code over both languages. Per-language LoC queries are now just summaries. --- java/ql/src/Metrics/Summaries/LinesOfCode.ql | 8 ++++---- java/ql/src/Metrics/Summaries/LinesOfCodeJava.ql | 13 +++++++++++++ java/ql/src/Metrics/Summaries/LinesOfCodeKotlin.ql | 1 - 3 files changed, 17 insertions(+), 5 deletions(-) create mode 100644 java/ql/src/Metrics/Summaries/LinesOfCodeJava.ql diff --git a/java/ql/src/Metrics/Summaries/LinesOfCode.ql b/java/ql/src/Metrics/Summaries/LinesOfCode.ql index 62c19d1b932..883c99b4bce 100644 --- a/java/ql/src/Metrics/Summaries/LinesOfCode.ql +++ b/java/ql/src/Metrics/Summaries/LinesOfCode.ql @@ -1,8 +1,8 @@ /** * @id java/summary/lines-of-code - * @name Total lines of Java code in the database - * @description The total number of lines of code across all Java files. This is a useful metric of the size of a database. - * For all Java files that were seen during the build, this query counts the lines of code, excluding whitespace + * @name Total lines of Java+Kotlin code in the database + * @description The total number of lines of code across all Java and Kotlin files. This is a useful metric of the size of a database. + * For all source files that were seen during the build, this query counts the lines of code, excluding whitespace * or comments. * @kind metric * @tags summary @@ -11,4 +11,4 @@ import java -select sum(CompilationUnit f | f.fromSource() and f.isJavaSourceFile() | f.getNumberOfLinesOfCode()) +select sum(CompilationUnit f | f.fromSource() | f.getNumberOfLinesOfCode()) diff --git a/java/ql/src/Metrics/Summaries/LinesOfCodeJava.ql b/java/ql/src/Metrics/Summaries/LinesOfCodeJava.ql new file mode 100644 index 00000000000..e9142225051 --- /dev/null +++ b/java/ql/src/Metrics/Summaries/LinesOfCodeJava.ql @@ -0,0 +1,13 @@ +/** + * @id java/summary/lines-of-code-java + * @name Total lines of Java code in the database + * @description The total number of lines of code across all Java files. This is a useful metric of the size of a database. + * For all Java 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() and f.isJavaSourceFile() | f.getNumberOfLinesOfCode()) diff --git a/java/ql/src/Metrics/Summaries/LinesOfCodeKotlin.ql b/java/ql/src/Metrics/Summaries/LinesOfCodeKotlin.ql index 0093bc0a98f..99966db1dc8 100644 --- a/java/ql/src/Metrics/Summaries/LinesOfCodeKotlin.ql +++ b/java/ql/src/Metrics/Summaries/LinesOfCodeKotlin.ql @@ -6,7 +6,6 @@ * or comments. * @kind metric * @tags summary - * lines-of-code */ import java From d816035da6209f7766232badc9cd51b083c70b8f Mon Sep 17 00:00:00 2001 From: Ian Lynagh Date: Fri, 20 Oct 2023 13:02:11 +0100 Subject: [PATCH 2/3] Java/Kotlin: Tweak LoC message --- java/ql/src/Metrics/Summaries/LinesOfCode.ql | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/java/ql/src/Metrics/Summaries/LinesOfCode.ql b/java/ql/src/Metrics/Summaries/LinesOfCode.ql index 883c99b4bce..769a3476ed2 100644 --- a/java/ql/src/Metrics/Summaries/LinesOfCode.ql +++ b/java/ql/src/Metrics/Summaries/LinesOfCode.ql @@ -1,6 +1,6 @@ /** * @id java/summary/lines-of-code - * @name Total lines of Java+Kotlin code in the database + * @name Total lines of Java/Kotlin code in the database * @description The total number of lines of code across all Java and Kotlin files. This is a useful metric of the size of a database. * For all source files that were seen during the build, this query counts the lines of code, excluding whitespace * or comments. From 26634a32665fcac8822c21229ce46ba574511cce Mon Sep 17 00:00:00 2001 From: Ian Lynagh Date: Fri, 20 Oct 2023 13:04:39 +0100 Subject: [PATCH 3/3] Java/Kotlin: Add a changenote for the lines-of-code changes --- java/ql/src/change-notes/2023-10-20-lines-of-code.md | 4 ++++ 1 file changed, 4 insertions(+) create mode 100644 java/ql/src/change-notes/2023-10-20-lines-of-code.md diff --git a/java/ql/src/change-notes/2023-10-20-lines-of-code.md b/java/ql/src/change-notes/2023-10-20-lines-of-code.md new file mode 100644 index 00000000000..b6b49aba7f9 --- /dev/null +++ b/java/ql/src/change-notes/2023-10-20-lines-of-code.md @@ -0,0 +1,4 @@ +--- +category: minorAnalysis +--- +* java/summary/lines-of-code now gives the total number of lines of Java and Kotlin code, and is the only query tagged `lines-of-code`. java/summary/lines-of-code-java and java/summary/lines-of-code-kotlin give the per-language counts.