Php_codesniffer: how to fix End of line character is invalid; expected "\n" but found "\r\n" in centos or window

Created on 16 Jul 2019  路  4Comments  路  Source: squizlabs/PHP_CodeSniffer

how to fix End of line character is invalid; expected "\n" but found "\r\n" in centos or window , but in linux or macos it is ok

Awaiting Feedback Question

Most helpful comment

The EOL (End of Line) character can be changed by setting this rule to the ruleset:

<rule ref="Generic.Files.LineEndings">
    <properties>
        <property name="eolChar" value="\n"/>
    </properties>
</rule>

The default character is \n which is the Unix EOL character. Personally disabled this check by the following rule:

<rule ref="Generic.Files.LineEndings">
    <exclude name="Generic.Files.LineEndings.InvalidEOLChar"/>
</rule>

And let the Git manage the EOL cross the platforms.

All 4 comments

I'm not really sure what you are asking. Do you want to know how to change the end of line character in text files? Or are you reporting that the check is working differently on windows vs mac OS?

If the check is working differently, I'd suggest making sure you are checking the same code with the same coding standard on all platforms. Using the -vv command line argument while testing a single small file would be the place to start. Compare the output, which should be identical.

Closing due to lack of feedback.

Hey , I am also facing this issue on only Windows. Is there any configration which solves this for every Platform?

The EOL (End of Line) character can be changed by setting this rule to the ruleset:

<rule ref="Generic.Files.LineEndings">
    <properties>
        <property name="eolChar" value="\n"/>
    </properties>
</rule>

The default character is \n which is the Unix EOL character. Personally disabled this check by the following rule:

<rule ref="Generic.Files.LineEndings">
    <exclude name="Generic.Files.LineEndings.InvalidEOLChar"/>
</rule>

And let the Git manage the EOL cross the platforms.

Was this page helpful?
0 / 5 - 0 ratings