Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Printing static code analysis errors in log #236

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,15 @@ If you had a `jar:test-jar` execution, delete it and add to `properties`:
<no-test-jar>false</no-test-jar>
```

### Verbose error from Spotbugs

You can have a more verbose error message from static code analysis, Spotbugs, by setting these properties:
```xml
<violations.maxViolations>0</violations.maxViolations>
<findbugs.failOnError>false</findbugs.failOnError>
<spotbugs.failOnError>false</spotbugs.failOnError>
```

## Java support

The plugin POM is designed for plugin builds with JDK 8 or above,
Expand Down
52 changes: 52 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -70,13 +70,19 @@
<findbugs.effort>default</findbugs.effort>
<!-- Whether the build should fail if SpotBugs finds any error. -->
<!-- It is strongly encouraged to leave it as true. Use false with care only in transient situations. -->
<!-- See also violations.maxViolations -->
<spotbugs.failOnError>${findbugs.failOnError}</spotbugs.failOnError>
<!-- Defines a SpotBugs threshold. Use "Low" to discover low-priority bugs.
Hint: SpotBugs considers some real NPE risks in Jenkins as low-priority issues, it is recommended to enable it in plugins.
-->
<spotbugs.threshold>${findbugs.threshold}</spotbugs.threshold>
<!-- Defines a SpotBugs effort. Use "Max" to maximize the scan depth -->
<spotbugs.effort>${findbugs.effort}</spotbugs.effort>

<!-- Maximum allowed number of violations found with static code analysis, or else fail the build. -->
<!-- You can set the spotbugs.failOnError to false and set violations.maxViolations to 0 to get a more verbose error in the build log. -->
<violations.maxViolations>999999</violations.maxViolations>
<violations.version>1.28</violations.version>

<!-- Whether to skip tests during release phase (they are executed in the prepare phase). -->
<release.skipTests>true</release.skipTests>
Expand Down Expand Up @@ -647,6 +653,52 @@
</execution>
</executions>
</plugin>
<plugin>
<groupId>se.bjurr.violations</groupId>
<artifactId>violations-maven-plugin</artifactId>
<version>${violations.version}</version>
<executions>
<execution>
<phase>verify</phase>
<goals>
<goal>violations</goal>
</goals>
<configuration>
<minSeverity>INFO</minSeverity>
<detailLevel>VERBOSE</detailLevel>
<maxViolations>${violations.maxViolations}</maxViolations>
<printViolations>true</printViolations>
<diffPrintViolations>false</diffPrintViolations>
<violations>
<violation>
<parser>FINDBUGS</parser>
<reporter>Spotbugs</reporter>
<folder>.</folder>
<pattern>.*/spotbugsXml\.xml$</pattern>
</violation>
<violation>
<parser>PMD</parser>
<reporter>Pmd</reporter>
<folder>.</folder>
<pattern>.*/pmd\.xml$</pattern>
</violation>
<violation>
<parser>CPD</parser>
<reporter>CPD</reporter>
<folder>.</folder>
<pattern>.*/cpd\.xml$</pattern>
</violation>
<violation>
<parser>CHECKSTYLE</parser>
<reporter>Checkstyle</reporter>
<folder>.</folder>
<pattern>.*/checkstyle-result\.xml$</pattern>
</violation>
</violations>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
Expand Down