Precautions when using checkstyle version 6.6 or higher

In checkstyle version 6.6 and later If an error level violation of the convention is found in the analyzed source code, it will be output to standard output.

$ java -jar checkstyle-6.7-SNAPSHOT-all.jar -f xml -c /sun_checks.xml Test.java
<?xml version="1.0" encoding="UTF-8"?>
<checkstyle version="6.7-SNAPSHOT">
<file name="/home/rivanov/tmp/cs_tests/Test.java">
......
</file>
</checkstyle>
Checkstyle ends with 12 errors.

Now spits out the message Checkstyle ends with XXX errors. on the last line. https://github.com/checkstyle/checkstyle/issues/1018#issuecomment-99271206

Therefore, if you output the analysis result to the standard output in XML format and pass it to another tool by connecting it with a pipe, parsing of the XML data may fail due to this one line.

As a solution, output to a file once as follows, You can pass it on to the next tool.

Before

java -jar checkstyle-6.7-SNAPSHOT-all.jar -f xml -c /sun_checks.xml \
| bundle exec saddler report \
    --require saddler/reporter/github \
    --reporter Saddler::Reporter::Github::CommitReviewComment

After

java -jar checkstyle-6.7-SNAPSHOT-all.jar -f xml -c /sun_checks.xml -o result.xml

bundle exec saddler report \
    --require saddler/reporter/github \
    --reporter Saddler::Reporter::Github::CommitReviewComment \
    < result.xml

Recommended Posts

Precautions when using checkstyle version 6.6 or higher
Precautions when using checkboxes in Thymeleaf
Don't forget setCalendar or setTimeZone when using Java DateFormat
Error when using SnapKit
Precautions when using Mockito.anyString as an argument when Mocking with Mockito