gradle/gradle · warning

Checkstyle rule violations were found. See the report at: {}

Error message

Checkstyle rule violations were found. See the report at: {}

What it means

After running Checkstyle, Gradle parses the Checkstyle XML report. If violations exist but the build is configured not to fail on them (ignoreFailures=true, or the ant failure property was not set while the report still lists violations), Gradle logs this warning with a clickable link to the report instead of throwing MarkedVerificationException. The build passes even though the code violates the configured Checkstyle rules.

Source

Thrown at platforms/jvm/code-quality-workers/src/main/java/org/gradle/api/plugins/quality/internal/CheckstyleInvoker.java:179

                ant.createNode("param", ImmutableMap.of("name", "gradleVersion", "expression", GradleVersion.current().toString()));
                ant.createNode("style", Collections.emptyMap(), () ->
                    ant.createNode("string", ImmutableMap.of("value", stylesheet))
                );
            });
        }

        if (isHtmlReportEnabledOnly(isXmlRequired, isHtmlRequired)) {
            GFileUtils.deleteQuietly(xmlOutputLocation);
        }

        Node reportXml = parseCheckstyleXml(isXmlRequired, xmlOutputLocation);
        String message = getMessage(isXmlRequired, xmlOutputLocation, isHtmlRequired, htmlOutputLocation, isSarifRequired, sarifOutputLocation, reportXml);
        boolean hasAFailure = ant.getProjectProperties().get(FAILURE_PROPERTY_NAME) != null;
        if (hasAFailure && !ignoreFailures) {
            throw new MarkedVerificationException(message);
        } else {
            if (violationsExist(reportXml)) {
                LOGGER.warn(message);
            }
        }
    }

    @Nullable
    private static File getXmlOutputLocation(CheckstyleActionParameters parameters, boolean isXmlRequired, boolean isHtmlRequired) {
        File xmlOutputLocation = parameters.getXmlOutputLocation().getAsFile().getOrNull();
        if (isHtmlReportEnabledOnly(isXmlRequired, isHtmlRequired)) {
            checkNotNull(xmlOutputLocation, "Xml report output location is required when html report is requested.");
            return new File(parameters.getTemporaryDir().getAsFile().get(), xmlOutputLocation.getName());
        }
        return xmlOutputLocation;
    }

    private static JavaVersion determineCheckstyleJavaVersion(ClassLoader antLoader) {
        InputStream checkstyleTask = antLoader.getResourceAsStream("com/puppycrawl/tools/checkstyle/CheckStyleTask.class");
        if (checkstyleTask == null) {
            checkstyleTask = antLoader.getResourceAsStream("com/puppycrawl/tools/checkstyle/ant/CheckstyleAntTask.class");

View on GitHub (pinned to 534f27719b)

Solutions

  1. Open the linked report (XML/HTML/SARIF) and fix the reported violations
  2. Remove checkstyle { ignoreFailures = true } so the build fails again on violations
  3. If ratcheting, set checkstyle { maxWarnings = <current count> } and lower it with every change toward 0
  4. Suppress justified findings in a checkstyle-suppressions.xml instead of globally ignoring failures

Example fix

// before: violations silently pass with a warning
checkstyle {
    ignoreFailures = true
}

// after: fail on violations, ratchet from the current count
checkstyle {
    ignoreFailures = false
    maxWarnings = 42 // lower as violations are fixed, target 0
}
Defensive patterns

Strategy: validation

Validate before calling

// fail the build when checkstyle violations exist, independent of ignoreFailures
tasks.withType(Checkstyle).configureEach {
    doLast {
        def xml = reports.xml.outputLocation.asFile.get()
        def count = new XmlSlurper().parse(xml).'**'.count { it.name() == 'error' }
        if (count > 0) {
            throw new GradleException("${count} checkstyle violations - see ${xml}")
        }
    }
}

Prevention

When it happens

Trigger: checkstyle { ignoreFailures = true } while the analyzed source has violations, or a maxWarnings/maxErrors threshold high enough that the task passes while reportXml still contains error entries, so violationsExist(reportXml) is true and the warn branch runs instead of the throw.

Common situations: Teams that enabled ignoreFailures temporarily when introducing Checkstyle and forgot to remove it; builds ratcheting violations down via maxWarnings; HTML-only report setups where the XML is deleted and the message points at the html/sarif report.

Related errors


AI-assisted analysis of gradle/gradle@534f27719b (2026-08-22). Data as JSON: /api/errors/919aa7b9a7fc4593. Report an issue: GitHub.