-
-
Notifications
You must be signed in to change notification settings - Fork 4k
Closed
Description
NewlineAtEndOfFile only checks the end of the file for bytes matching the EOL type , for the length of the EOL type.
As lf is only one byte, it does not detect that the previous byte cr before the lf.
Therefore a crlf combination at EOF is accepted as a valid match for lineSeparator=lf
$ cat TestConfig.xml
<?xml version="1.0"?>
<!DOCTYPE module PUBLIC
"-//Puppy Crawl//DTD Check Configuration 1.3//EN"
"http://www.puppycrawl.com/dtds/configuration_1_3.dtd">
<module name="Checker">
<module name="NewlineAtEndOfFile">
<property name="lineSeparator" value="lf"/>
</module>
</module>
$ echo -ne "1\r\n" > newline.txt
$ hd newline.txt
00000000 31 0d 0a |1..|
00000003
$ java -jar checkstyle-7.7-all.jar -c TestConfig.xml newline.txt
Starting audit...
Audit done.
Expected: violation as last line is "0d0a" but "0a"(lf) is expected.
Reactions are currently unavailable