Hello,

In my dev environment (Windows 10, IntelliJ, Git checking out with LF line
endings) I see 39 checkstyle errors for our tests related to java files not
ending with a newline.

However on inspecting one of the files, ModelFormFieldTest, I can see that
it does end with a newline.

A quick google on the subject turned up
https://stackoverflow.com/questions/997021/how-to-get-rid-of-checkstyle-message-file-does-not-end-with-a-newline
.

It appears that checkstyle will assume the line endings of the environment
where it is being run. In my case, Windows, it will assume line endings of
CRLF, rather than the LF that I am using.

If I modify the checkstyle configuration to specify LF for line endings
using:

<module name="NewlineAtEndOfFile">
    <property name="lineSeparator" value="lf" />
</module>

all the checkstyle errors in tests are resolved.

*Question: Does anyone see any issues in telling Checkstyle to use LF line
endings when it performs its checking?*

The interesting thing was that even if I convert a file to use CRLF line
endings, the above lineSeparator confgiuration for the NewlineAtEndOfFile
checkstyle module would still pass.

The above change also had the pleasant outcome of reducing checkstyle
errors for main code from 1055 files with violations to 956.

Dan

-- 
Daniel Watford

Reply via email to