From 0253b9d3cd2cfab4df08eb36dd48dd8a335e2171 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Juan=20Mart=C3=ADn=20Sotuyo=20Dodero?= Date: Sat, 14 Sep 2024 01:33:20 -0300 Subject: [PATCH 1/4] Ignore generated-sources in coverage reports - We don't test it directly, nor is it our job - A bad grammar won't be processed, or fail in subtle ways only detectable in specific tests on the AST (which is included) --- pom.xml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/pom.xml b/pom.xml index 3c410ebe80..f2cb4d826c 100644 --- a/pom.xml +++ b/pom.xml @@ -612,6 +612,11 @@ org.jacoco jacoco-maven-plugin 0.8.11 + + + **/target/generated-sources/** + + org.cyclonedx From 029130a478e1c4c585c965dca224961df18c7034 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Juan=20Mart=C3=ADn=20Sotuyo=20Dodero?= Date: Tue, 17 Sep 2024 17:00:42 -0300 Subject: [PATCH 2/4] Use a custom annotation to ignore javacc generated code --- javacc-wrapper.xml | 21 ++++++++++++----- .../sourceforge/pmd/annotation/Generated.java | 23 +++++++++++++++++++ pom.xml | 7 +----- 3 files changed, 39 insertions(+), 12 deletions(-) create mode 100644 pmd-core/src/main/java/net/sourceforge/pmd/annotation/Generated.java diff --git a/javacc-wrapper.xml b/javacc-wrapper.xml index 2c43e086d8..bbd50e21a4 100644 --- a/javacc-wrapper.xml +++ b/javacc-wrapper.xml @@ -224,6 +224,11 @@ + + ${parser-name} + + @@ -262,7 +267,8 @@ - + @@ -272,7 +278,8 @@ - + @@ -385,11 +392,12 @@ - +'/> @@ -534,8 +542,9 @@ public final class ${token-constants-name} \{${line.separator} - + diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/annotation/Generated.java b/pmd-core/src/main/java/net/sourceforge/pmd/annotation/Generated.java new file mode 100644 index 0000000000..ab9b46f465 --- /dev/null +++ b/pmd-core/src/main/java/net/sourceforge/pmd/annotation/Generated.java @@ -0,0 +1,23 @@ +/* + * BSD-style license; for more info see http://pmd.sourceforge.net/license.html + */ + +package net.sourceforge.pmd.annotation; + +import java.lang.annotation.Documented; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; + +/** + * Marks a class as generated code, and therefore to be ignored for code coverage purposes. + * + * @since 7.6.0 + */ +@Retention(RetentionPolicy.CLASS) +@Documented +public @interface Generated { + + /** The generator that produced this code */ + String value() default ""; + +} diff --git a/pom.xml b/pom.xml index f2cb4d826c..216fad4056 100644 --- a/pom.xml +++ b/pom.xml @@ -611,12 +611,7 @@ org.jacoco jacoco-maven-plugin - 0.8.11 - - - **/target/generated-sources/** - - + 0.8.12 org.cyclonedx From cae71e7a5e72bba07867a38072b9e580aebfa97e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Juan=20Mart=C3=ADn=20Sotuyo=20Dodero?= Date: Tue, 17 Sep 2024 17:09:29 -0300 Subject: [PATCH 3/4] Be consistent in how we replace tokens --- javacc-wrapper.xml | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/javacc-wrapper.xml b/javacc-wrapper.xml index bbd50e21a4..05837e96ba 100644 --- a/javacc-wrapper.xml +++ b/javacc-wrapper.xml @@ -224,9 +224,7 @@ - - ${parser-name} + From d77a63da952feebb53c01b8da45bca600b49f35e Mon Sep 17 00:00:00 2001 From: Andreas Dangel Date: Thu, 3 Oct 2024 20:29:53 +0200 Subject: [PATCH 4/4] [doc] Update release notes (#5241) --- docs/pages/release_notes.md | 1 + 1 file changed, 1 insertion(+) diff --git a/docs/pages/release_notes.md b/docs/pages/release_notes.md index a0bd73f9c6..978145ff2e 100644 --- a/docs/pages/release_notes.md +++ b/docs/pages/release_notes.md @@ -29,6 +29,7 @@ This is a {{ site.pmd.release_type }} release. ### ✨ External Contributions * [#5208](https://github.com/pmd/pmd/pull/5208): \[doc] Added Codety to "Tools / Integrations" - [Tony](https://github.com/random1223) (@random1223) +* [#5241](https://github.com/pmd/pmd/pull/5241): \Ignore javacc code in coverage report - [Juan Martín Sotuyo Dodero](https://github.com/jsotuyod) (@jsotuyod) {% endtocmaker %}