Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NewlineAtEndOfFile with LF_CR_CRLF does not work properly #6508

Closed
Vampire opened this issue Mar 5, 2019 · 6 comments

Comments

Projects
None yet
3 participants
@Vampire
Copy link
Contributor

commented Mar 5, 2019

/var/tmp $ cat config.xml
<?xml version="1.0"?>
<!DOCTYPE module PUBLIC
        "-//Checkstyle//DTD Checkstyle Configuration 1.3//EN"
        "https://checkstyle.org/dtds/configuration_1_3.dtd">
<module name="Checker">
    <module name="NewlineAtEndOfFile">
        <property name="lineSeparator" value="lf_cr_crlf"/>
    </module>
</module>

/var/tmp $ xxd foo.properties
00000000: 0a                                       .

/var/tmp $ java -Duser.language=en -Duser.country=US -jar checkstyle-8.18-all.jar -c config.xml foo.properties
Starting audit...
[ERROR] D:\Sourcecode\other\discord-logger\tmp\foo.properties:1: File does not end with a newline. [NewlineAtEndOfFile]
Audit done.
Checkstyle ends with 1 errors.

With a file that only contains a linefeed character the NewlineAtEndOfFile check fails, because NewlineAtEndOfFile with LF_CR_CRLF requires to have at least two characters in the file with CS 8.18, even when technically only the latter is checked actually.
Expected would be no violation.

https://checkstyle.org/property_types.html#lineSeparator
lf_cr_crlf is "lf, cr or crlf" in other words ANY

Vampire added a commit to Vampire/checkstyle that referenced this issue Mar 5, 2019

Issue checkstyle#6508: Do not fail NewlineAtEndOfFile check with LF_C…
…R_CRLF if file consists only of a newline character

Vampire added a commit to Vampire/checkstyle that referenced this issue Mar 5, 2019

Issue checkstyle#6508: Do not fail NewlineAtEndOfFile check with LF_C…
…R_CRLF if file consists only of a newline character

Vampire added a commit to Vampire/checkstyle that referenced this issue Mar 5, 2019

Issue checkstyle#6508: Do not fail NewlineAtEndOfFile check with LF_C…
…R_CRLF if file consists only of a newline character

Vampire added a commit to Vampire/checkstyle that referenced this issue Mar 10, 2019

Issue checkstyle#6508: Do not fail NewlineAtEndOfFile check with LF_C…
…R_CRLF if file consists only of a newline character

Vampire added a commit to Vampire/checkstyle that referenced this issue Mar 11, 2019

Issue checkstyle#6508: Do not fail NewlineAtEndOfFile check with LF_C…
…R_CRLF if file consists only of a newline character
@romani

This comment has been minimized.

Copy link
Member

commented Mar 16, 2019

@Vampire , please report issue as required our template.
As file will contain invisiable symbols please use some terminal tool to print file in hex codes.
Thanks in advance.

@romani

This comment has been minimized.

Copy link
Member

commented Mar 16, 2019

@Vampire , is it the same as #4074 ?

Vampire added a commit to Vampire/checkstyle that referenced this issue Mar 18, 2019

Issue checkstyle#6508: Do not fail NewlineAtEndOfFile check with LF_C…
…R_CRLF if file consists only of a newline character
@Vampire

This comment has been minimized.

Copy link
Contributor Author

commented Mar 19, 2019

No, #4074 is totally different.
#4074 says check is configured to check for LF, file has CRLF which ends in LF and thus is accepted.
This one says check is configured to use LF_CR_CRLF, so any should be accepted, file does only contain one byte which is LF, so should have no validation, but fails as the check for LF_CR_CRLF requires two bytes in the file to match.
I'll update according to the template, one moment.

@Vampire

This comment has been minimized.

Copy link
Contributor Author

commented Mar 19, 2019

I updated the inital description with a variation of the report template

@rnveach

This comment has been minimized.

Copy link
Member

commented Apr 8, 2019

I am marking this approved.

Vampire added a commit to Vampire/checkstyle that referenced this issue Apr 10, 2019

Issue checkstyle#6508: Do not fail NewlineAtEndOfFile check with LF_C…
…R_CRLF if file consists only of a newline character

Vampire added a commit to Vampire/checkstyle that referenced this issue Apr 11, 2019

Issue checkstyle#6508: Do not fail NewlineAtEndOfFile check with LF_C…
…R_CRLF if file consists only of a newline character

Vampire added a commit to Vampire/checkstyle that referenced this issue Apr 11, 2019

Issue checkstyle#6508: Do not fail NewlineAtEndOfFile check with LF_C…
…R_CRLF if file consists only of a newline character

Vampire added a commit to Vampire/checkstyle that referenced this issue Apr 16, 2019

Issue checkstyle#6508: Do not fail NewlineAtEndOfFile check with LF_C…
…R_CRLF if file consists only of a newline character

@romani romani removed their assignment Apr 27, 2019

Vampire added a commit to Vampire/checkstyle that referenced this issue May 13, 2019

Issue checkstyle#6508: Do not fail NewlineAtEndOfFile check with LF_C…
…R_CRLF if file consists only of a newline character

rnveach added a commit that referenced this issue May 13, 2019

Issue #6508: Do not fail NewlineAtEndOfFile check with LF_CR_CRLF if …
…file consists only of a newline character

@rnveach rnveach added the bug label May 13, 2019

@rnveach rnveach added this to the 8.21 milestone May 13, 2019

@rnveach

This comment has been minimized.

Copy link
Member

commented May 13, 2019

Fix was merged

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.