apache / apache/maven-checkstyle-plugin

[MCHECKSTYLE-104] CheckstyleViolationCheckMojo: More flexible checkstyle:check-inflicted build failures

Open
#443 2 comments 0 reactions 0 assignees View on GitHub
enhancement priority:major
Dominant language
Java
Stars
97
Forks
67
Avg merge
14h 50m
Merged PRs (30d)
6

Description

**[Kaloyan Enimanev](https://issues.apache.org/jira/secure/ViewProfile.jspa?name=kenimanev)** opened **[MCHECKSTYLE-104](https://issues.apache.org/jira/browse/MCHECKSTYLE-104?redirect=false)** and commented

Hey guys,
first of all let me thank you for the wonderful job that you all do. Our company's build process has rocketed a century forward after we replaced Ant with Maven.

We're currently trying to migrate from Maven1 to Maven2. We have a Jelly goal in our old M1 build that does similar job to "checkstyle:check" in M2, but it verifies that a project does not have more than `X` Checkstyle Errors **and** `Y` Checkstyle Warnings. That was not entirely possible to configure with M2, where one can choose to fail the build on more than 0 Errors **or** Warnings, where 0 is not a configurable value in contrast with `X` and `Y`.

I have scribbled several changes in

`/maven-checkstyle-plugin/src/main/java/org/apache/maven/plugin/checkstyle/CheckstyleViolationCheckMojo.java`

where I basically replaced the parameter `violationSeverity` with 3 new parameters (`maxErrors`, `maxWarnings`, `maxInfos`) allowing the user a more flexible configuration of checkstyle-inflicted build failures.

Example :
The configuration

```xml

maven-checkstyle-plugin

true
0
100
.....

......
```

will fail the build of a project that has more than 0 Checkstyle Errors or more than 100 Checkstyle Warnings.

If you find such the feature useful and want to include it in some of the next releases of `maven-checkstyle-plugin` I will be happy to do the additional Documentation/Test Cases.

---

**Affects:** 2.2

**Attachments:**
- [CheckstyleViolationCheckMojo.java](https://issues.apache.org/jira/secure/attachment/12714754/CheckstyleViolationCheckMojo.java) (_7.99 kB_)

**Issue Links:**
- [MCHECKSTYLE-113](https://issues.apache.org/jira/browse/MCHECKSTYLE-113) Set the number of accepted violations for checkstyle:check

1 votes, 3 watchers

Contributor guide

No contributing guide indexed for this repository

Research direction

Start with maven-checkstyle-plugin/src/main/java/org/apache/maven/plugin/checkstyle/CheckstyleViolationCheckMojo.java and review the related MCHECKSTYLE-113 issue. Check how the proposed maxErrors, maxWarnings, and maxInfos configuration should affect build failures, then add the documentation and test cases requested in the issue; done means thresholds can be configured independently.

Written by the indexing model from the issue text.

Assessment

Tech stack
java
Domain
build-system
Issue type
Feature
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
43/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.