Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to suppress warnings in maven output when using maven-checkstyle-plugin?

My build fails on checkstyle errors (not warnings). As long as there are any checkstyle errors i want the warnings are not shown in the (maven produced) output. How to achieve this?

# First is error, should be reported, second is a warning, should not be reported in the maven output. 
...data/Decimal.java:286:31: '7L' is a magic number.
.../data/Decimal.java:296:5: warning: Missing a Javadoc comment.

UPDATE: See my comment. This question is NOT about suppressing specific warnings! It is only about not displaying all warnings in the maven output!

like image 954
rmuller Avatar asked Jul 07 '15 07:07

rmuller


People also ask

How do I fix Checkstyle issue in Intellij?

You can configure your Checkstyle rules in the Idea's Code Style config (File -> Settings -> Code Style) and then reformat the code (Code -> Reformat Code [Ctrl+Alt+L]) according to the rules (you can apply it to the whole code base at once). Save this answer. Show activity on this post. reformat your code.

What is Maven Checkstyle plugin used for?

checkstyle:checkstyle is a reporting goal that performs Checkstyle analysis and generates a report on violations. checkstyle:checkstyle-aggregate is a reporting goal that performs Checkstyle analysis and generates an aggregate HTML report on violations in a multi-module reactor build.


2 Answers

There is no such option in checkstyle.

You can use filters to show you only errors, but there is no option to hide events by level if higher level exists. You can write such filter http://checkstyle.sourceforge.net/writingfilters.html#Writing_Filters

like image 149
Roman Ivanov Avatar answered Sep 22 '22 00:09

Roman Ivanov


Had the same problem with lots of warnings. As a quick hack it is possible to just filter out "warning" lines with inverted grep match:

mvn clean install | grep -v warning
like image 29
Anton Lavrenov Avatar answered Sep 20 '22 00:09

Anton Lavrenov