diff --git a/README.md b/README.md index c32e5e0..be4bba2 100644 --- a/README.md +++ b/README.md @@ -14,6 +14,7 @@ highly accurate algorithm. * Detects embedded languages (e.g. CSS in HTML) * Accommodates nested comments * Ability to associate custom file extensions with languages and remove unwanted associations +* Provides a number of [report formats](#reports) (e.g. JSON, XML) * Uses the [locc4j](https://github.com/cthing/locc4j) library, which is modeled after the [tokei](https://github.com/XAMPPRocky/tokei) line counting tool @@ -133,14 +134,14 @@ locc { The plugin is capable of generating a line count report in a number of formats. Note that different formats provide different amounts of information as described in the following table. -| Format | Project Information | Counts Per Language | Counts Per File | Counts Per Language Per File | Schema | -|--------|---------------------|---------------------|-----------------|------------------------------|--------------------------------------------| -| CSV | | ✅ | | | | -| HTML | ✅ | ✅ | ✅ | | | -| JSON | ✅ | ✅ | ✅ | ✅ | https://www.cthing.com/schemas/locc-1.json | -| Text | ✅ | ✅ | ✅ | | | -| XML | ✅ | ✅ | ✅ | ✅ | https://www.cthing.com/schemas/locc-1.xsd | -| YAML | ✅ | ✅ | ✅ | ✅ | https://www.cthing.com/schemas/locc-1.json | +| Format | Project Information | Counts Per Language | Counts Per File | Counts Per Language Per File | Example | Schema | +|--------|---------------------|---------------------|-----------------|------------------------------|-----------------------------------------|-----------------------------------------------------------| +| CSV | | ✅ | | | [locc.csv](example-reports/locc.csv) | | +| HTML | ✅ | ✅ | ✅ | | [locc.html](example-reports/locc.html) | | +| JSON | ✅ | ✅ | ✅ | ✅ | [locc.json](example-reports/locc.json) | [locc-1.json](https://www.cthing.com/schemas/locc-1.json) | +| Text | ✅ | ✅ | ✅ | | [locc.txt](example-reports/locc.txt) | | +| XML | ✅ | ✅ | ✅ | ✅ | [locc.xml](example-reports/locc.xml) | [locc-1.xsd](https://www.cthing.com/schemas/locc-1.xsd) | +| YAML | ✅ | ✅ | ✅ | ✅ | [locc.yaml](example-reports/locc.yaml) | [locc-1.json](https://www.cthing.com/schemas/locc-1.json) | The report for each format is generated as `build/reports/locc/locc.{csv, html, json, txt, xml, yaml}`. By default, the plugin will generate a report in the HTML and XML formats. Configure the task reports to control which file diff --git a/example-reports/locc.csv b/example-reports/locc.csv new file mode 100644 index 0000000..4fe096b --- /dev/null +++ b/example-reports/locc.csv @@ -0,0 +1,5 @@ +ID,Name,Description,Total Lines,Code Lines,Comment Lines,Blank Lines +ALL,All,All languages,78,40,29,9 +Css,CSS,Cascading Style Sheets language,7,7,0,0 +Html,HTML,HyperText Markup Language,12,12,0,0 +Java,Java,Java programming language,59,21,29,9 diff --git a/example-reports/locc.html b/example-reports/locc.html new file mode 100644 index 0000000..67d5f5e --- /dev/null +++ b/example-reports/locc.html @@ -0,0 +1,204 @@ + + + + + Line Count Report For simple-project + + + +

Line Count Report For simple-project

+ +

Summary

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Projectsimple-project
Versionunspecified
Report date2024-06-13T12:17:03-07:00
Number of files5
Number of languages3
Unrecognized files0
Total lines78
Code lines40
Comment lines29
Blank lines9
+ +

Line Count by Language

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameDescriptionTotal LinesCode LinesComment LinesBlank Lines
CSSCascading Style Sheets language7700
HTMLHyperText Markup Language121200
JavaJava programming language5921299
Total7840299
+ +

Line Count by File

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
PathnameTotal LinesCode LinesComment LinesBlank LinesLanguages
src/main/java/com/cthing/testproject/HelloWorld.java3211174Java
src/main/java/com/cthing/testproject/package-info.java10181Java
src/main/resources/sample.css7700CSS
src/main/resources/sample.html121200HTML
src/test/java/com/cthing/testproject/HelloWorldTest.java17944Java
Total7840299
+ + diff --git a/example-reports/locc.json b/example-reports/locc.json new file mode 100644 index 0000000..0beb124 --- /dev/null +++ b/example-reports/locc.json @@ -0,0 +1,132 @@ +{ + "formatVersion": 1, + "date": "2024-06-13T12:17:03-07:00", + "projectName": "simple-project", + "projectVersion": "unspecified", + "numFiles": 5, + "numUnrecognized": 0, + "numLanguages": 3, + "totalLines": 78, + "codeLines": 40, + "commentLines": 29, + "blankLines": 9, + "languages": [ + { + "name": "Css", + "displayName": "CSS", + "description": "Cascading Style Sheets language", + "website": "https:\/\/www.w3.org\/Style\/CSS\/", + "totalLines": 7, + "codeLines": 7, + "commentLines": 0, + "blankLines": 0 + }, + { + "name": "Html", + "displayName": "HTML", + "description": "HyperText Markup Language", + "website": "https:\/\/en.wikipedia.org\/wiki\/HTML", + "totalLines": 12, + "codeLines": 12, + "commentLines": 0, + "blankLines": 0 + }, + { + "name": "Java", + "displayName": "Java", + "description": "Java programming language", + "website": "https:\/\/en.wikipedia.org\/wiki\/Java_(programming_language)", + "totalLines": 59, + "codeLines": 21, + "commentLines": 29, + "blankLines": 9 + } + ], + "files": [ + { + "pathname": "src\/main\/java\/com\/cthing\/testproject\/HelloWorld.java", + "numLanguages": 1, + "totalLines": 32, + "codeLines": 11, + "commentLines": 17, + "blankLines": 4, + "languages": [ + { + "name": "Java", + "totalLines": 32, + "codeLines": 11, + "commentLines": 17, + "blankLines": 4 + } + ] + }, + { + "pathname": "src\/main\/java\/com\/cthing\/testproject\/package-info.java", + "numLanguages": 1, + "totalLines": 10, + "codeLines": 1, + "commentLines": 8, + "blankLines": 1, + "languages": [ + { + "name": "Java", + "totalLines": 10, + "codeLines": 1, + "commentLines": 8, + "blankLines": 1 + } + ] + }, + { + "pathname": "src\/main\/resources\/sample.css", + "numLanguages": 1, + "totalLines": 7, + "codeLines": 7, + "commentLines": 0, + "blankLines": 0, + "languages": [ + { + "name": "Css", + "totalLines": 7, + "codeLines": 7, + "commentLines": 0, + "blankLines": 0 + } + ] + }, + { + "pathname": "src\/main\/resources\/sample.html", + "numLanguages": 1, + "totalLines": 12, + "codeLines": 12, + "commentLines": 0, + "blankLines": 0, + "languages": [ + { + "name": "Html", + "totalLines": 12, + "codeLines": 12, + "commentLines": 0, + "blankLines": 0 + } + ] + }, + { + "pathname": "src\/test\/java\/com\/cthing\/testproject\/HelloWorldTest.java", + "numLanguages": 1, + "totalLines": 17, + "codeLines": 9, + "commentLines": 4, + "blankLines": 4, + "languages": [ + { + "name": "Java", + "totalLines": 17, + "codeLines": 9, + "commentLines": 4, + "blankLines": 4 + } + ] + } + ] +} diff --git a/example-reports/locc.txt b/example-reports/locc.txt new file mode 100644 index 0000000..dc0855b --- /dev/null +++ b/example-reports/locc.txt @@ -0,0 +1,44 @@ +Line Count Report For simple-project +-------------------------------------------------------------------------------- +Date: 2024-06-13T12:17:03-07:00 +Project version: unspecified +Number of files: 5 +Number unrecognized files: 0 +Number of languages: 3 +Total lines: 78 +Code lines: 40 +Comment lines: 29 +Blank lines: 9 + +Languages +--------- +CSS: Cascading Style Sheets language + Lines: 7 total, 7 code, 0 comment, 0 blank + +HTML: HyperText Markup Language + Lines: 12 total, 12 code, 0 comment, 0 blank + +Java: Java programming language + Lines: 59 total, 21 code, 29 comment, 9 blank + +Files +----- +src/main/java/com/cthing/testproject/HelloWorld.java + Lines: 32 total, 11 code, 17 comment, 4 blank + Languages: Java + +src/main/java/com/cthing/testproject/package-info.java + Lines: 10 total, 1 code, 8 comment, 1 blank + Languages: Java + +src/main/resources/sample.css + Lines: 7 total, 7 code, 0 comment, 0 blank + Languages: CSS + +src/main/resources/sample.html + Lines: 12 total, 12 code, 0 comment, 0 blank + Languages: HTML + +src/test/java/com/cthing/testproject/HelloWorldTest.java + Lines: 17 total, 9 code, 4 comment, 4 blank + Languages: Java diff --git a/example-reports/locc.xml b/example-reports/locc.xml new file mode 100644 index 0000000..d705ba5 --- /dev/null +++ b/example-reports/locc.xml @@ -0,0 +1,25 @@ + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/example-reports/locc.yaml b/example-reports/locc.yaml new file mode 100644 index 0000000..0105ac4 --- /dev/null +++ b/example-reports/locc.yaml @@ -0,0 +1,99 @@ +--- +formatVersion: 1 +date: '2024-06-13T12:17:03-07:00' +projectName: 'simple-project' +projectVersion: unspecified +numFiles: 5 +numUnrecognized: 0 +numLanguages: 3 +totalLines: 78 +codeLines: 40 +commentLines: 29 +blankLines: 9 +languages: + - name: Css + displayName: CSS + description: Cascading Style Sheets language + website: 'https://www.w3.org/Style/CSS/' + totalLines: 7 + codeLines: 7 + commentLines: 0 + blankLines: 0 + - name: Html + displayName: HTML + description: HyperText Markup Language + website: 'https://en.wikipedia.org/wiki/HTML' + totalLines: 12 + codeLines: 12 + commentLines: 0 + blankLines: 0 + - name: Java + displayName: Java + description: Java programming language + website: 'https://en.wikipedia.org/wiki/Java_(programming_language)' + totalLines: 59 + codeLines: 21 + commentLines: 29 + blankLines: 9 +files: + - pathname: 'src/main/java/com/cthing/testproject/HelloWorld.java' + numLanguages: 1 + totalLines: 32 + codeLines: 11 + commentLines: 17 + blankLines: 4 + languages: + - name: Java + totalLines: 32 + codeLines: 11 + commentLines: 17 + blankLines: 4 + - pathname: 'src/main/java/com/cthing/testproject/package-info.java' + numLanguages: 1 + totalLines: 10 + codeLines: 1 + commentLines: 8 + blankLines: 1 + languages: + - name: Java + totalLines: 10 + codeLines: 1 + commentLines: 8 + blankLines: 1 + - pathname: 'src/main/resources/sample.css' + numLanguages: 1 + totalLines: 7 + codeLines: 7 + commentLines: 0 + blankLines: 0 + languages: + - name: Css + totalLines: 7 + codeLines: 7 + commentLines: 0 + blankLines: 0 + - pathname: 'src/main/resources/sample.html' + numLanguages: 1 + totalLines: 12 + codeLines: 12 + commentLines: 0 + blankLines: 0 + languages: + - name: Html + totalLines: 12 + codeLines: 12 + commentLines: 0 + blankLines: 0 + - pathname: 'src/test/java/com/cthing/testproject/HelloWorldTest.java' + numLanguages: 1 + totalLines: 17 + codeLines: 9 + commentLines: 4 + blankLines: 4 + languages: + - name: Java + totalLines: 17 + codeLines: 9 + commentLines: 4 + blankLines: 4 +...