You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@maven.apache.org by "efegokdemir (via GitHub)" <gi...@apache.org> on 2026/09/25 07:09:49 UTC

[PR] Log lower-severity violations when checking [maven-checkstyle-plugin]

efegokdemir opened a new pull request, #716:
URL: https://github.com/apache/maven-checkstyle-plugin/pull/716

   ## Summary
   
   When `checkstyle:check` used `violationSeverity=error`, console reporting filtered out warning-level violations even though they were present in the Checkstyle result. This change keeps severity filtering for the failure/count decision while allowing all non-ignored reported violations to be logged.
   
   ## Changes
   
   - Remove the severity-threshold filter from console violation reporting.
   - Add a regression test covering warning output with `violationSeverity=error`.
   
   ## Testing
   
   - `mvn -pl . -Dtest=CheckstyleViolationCheckMojoTest -DfailIfNoTests=false -Dspotless.check.skip=true -Dspotless.apply.skip=true -Dcheckstyle.skip=true test` — passed
   - `mvn -DskipTests -Dspotless.apply.skip=true verify` — passed
   - `git diff --check` — passed
   - `mvn spotless:check -DskipTests` — not completed because the existing Palantir formatter failed with `NoSuchFieldError` on unchanged `CheckstyleProjectStub.java` under the installed JDK.
   
   This issue has no other open implementation PR and the fix is limited to the requested reporting behavior.
   
   AI assistance was used; the changes and validation were reviewed before submission.
   
   Fixes #648
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@maven.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Log lower-severity violations when checking [maven-checkstyle-plugin]

Posted by "slawekjaranowski (via GitHub)" <gi...@apache.org>.
slawekjaranowski commented on code in PR #716:
URL: https://github.com/apache/maven-checkstyle-plugin/pull/716#discussion_r4267252483


##########
src/test/java/org/apache/maven/plugins/checkstyle/CheckstyleViolationCheckMojoTest.java:
##########
@@ -132,4 +137,35 @@ public void testPlainOutputFile(CheckstyleViolationCheckMojo mojo) throws Except
     public void testNoFail(CheckstyleViolationCheckMojo mojo) throws Exception {
         mojo.execute();
     }
+
+    @InjectMojo(goal = "check", pom = "src/test/resources/plugin-configs/check-plugin-config.xml")
+    @MojoParameter(name = "outputFile", value = "src/test/resources/plugin-configs/check-plugin-warning-output.xml")
+    @MojoParameter(name = "skipExec", value = "true")
+    @MojoParameter(name = "failOnViolation", value = "false")
+    @MojoParameter(name = "violationSeverity", value = "error")
+    @MojoParameter(name = "logViolationsToConsole", value = "true")
+    @Test
+    public void testWarningsAreLoggedWhenSeverityIsError(
+            CheckstyleViolationCheckMojo mojo) throws Exception {
+        List<String> loggedMessages = new ArrayList<>();
+        Log log = (Log) Proxy.newProxyInstance(
+                Log.class.getClassLoader(),
+                new Class<?>[] {Log.class},
+                (proxy, method, args) -> {
+                    if (method.getName().startsWith("is") && method.getName().endsWith("Enabled")) {
+                        return true;
+                    }
+                    if (args != null && args.length > 0 && args[0] != null) {
+                        loggedMessages.add(String.valueOf(args[0]));
+                    }
+                    return null;
+                });

Review Comment:
   Instead of it you can inject `Log` in test and simply use moclkito to verify actions on it
   
   https://maven.apache.org/plugin-testing/maven-plugin-testing-harness/examples/complex-mojo-parameters.html#plugin-logger



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@maven.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org