Le 28/02/2020 à 10:07, Daniel Watford a écrit :
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

Hi Daniel,

Thanks for this information, I use also Windows (7) and was just to the point 
to look at the remaning issue with checkstyle.

+1 for your proposition

But I just tried after changing NewlineAtEndOfFile module as you suggest, and 
got this

   /C:\projectsASF\Git\ofbiz-framework>gradlew check > Configure project : You 
are using one or more deprecated Asciidoctor task or plugins. To help
   with migration run with --warnings=all > Task :compileJava UP-TO-DATE > Task 
:compileGroovy UP-TO-DATE > Task :processResources UP-TO-DATE > Task
   :classes UP-TO-DATE > Task :checkstyleMain Checkstyle rule violations were 
found. See the report at:
   
file:///C:/projectsASF/Git/ofbiz-framework/build/reports/checkstyle/main.html 
Checkstyle files with violations: 1038 Checkstyle violations by
   severity: [error:37692] > Task :compileTestJava UP-TO-DATE > Task 
:compileTestGroovy UP-TO-DATE > Task :processTestResources UP-TO-DATE > Task
   :testClasses UP-TO-DATE > Task :checkstyleTest > Task :test FAILED FAILURE: 
Build failed with an exception. * What went wrong: Execution failed
   for task ':test'. > 120/

Don't you have any checkstyle issues with trunk HEAD?
I checked my Git local config and see no reasons, any ideas?

Jacques

Reply via email to