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

Disable the Generic.Files.LineEndings rule #1880

Closed
1 task done
azaozz opened this issue Apr 7, 2020 · 2 comments
Closed
1 task done

Disable the Generic.Files.LineEndings rule #1880

azaozz opened this issue Apr 7, 2020 · 2 comments

Comments

@azaozz
Copy link

azaozz commented Apr 7, 2020

Bug Description

Please provide a clear and concise description of what the bug is.

Please see https://core.trac.wordpress.org/ticket/47411#comment:18.

The Generic.Files.LineEndings rule is incompatible with Subversion in the WordPress Core repository.

What did you expect to happen? What actually happened?

Expected: WPCS and SVN work well together.

Actual: The above rule enforces \n line endings in PHP files on Windows. However SVN enforces \r\n line endings as the WP Core files have svn:eol-style = native property. This results in redundant errors being reported and useless changes being made to all files when PHPCS/PHPCBF and SVN take over one another.

In addition there is no rule about line endings in the WordPress PHP Coding Standards. Line endings "management" is left for the version control systems, Subversion and/or Git. The Generic.Files.LineEndings should not be in the WPCS sniffs.

Tested Against develop branch?

  • I have verified the issue still exists in the develop branch of WPCS.
@jrfnl
Copy link
Member

jrfnl commented Apr 8, 2020

As I have stated before, different people work in different ways. People may have their local development environment set up in a different way than you have.

This can (and will) result in files having mixed line endings prior to commit depending on the local setup by devs.

If PHPCS - and especially PHPCBF - is run over files with mixed line endings, the results will be unreliable and this may result in incorrect fixes being made.

I am not prepared to offer any kind of support for any questions or bug reports related to this if that rule would get removed.

Aside from the fact that PHPCS will just replace the errors about incorrect line endings from the sniff with errors about files having mixed line endings, which is a PHPCS internal system warning, not based on any sniff.

I've told you before and I will repeat it again now: if you are comfortable with your personal dev environment not being susceptible to the "mixed line endings" issue, you can turn that rule off for your own local environment using a phpcs.xml file with the following content:

<?xml version="1.0"?>
<ruleset name="WP Core local">

	<rule ref="./phpcs.xml.dist">
		<exclude name="Generic.Files.LineEndings"/>
	</rule>
</ruleset>

Just don't come complaining about incorrect fixes being made.

@GaryJones
Copy link
Member

PSR-2 / PSR-12: LF

WordPress .editorconfig: LF

phpcs/phpcbf: LF

Git: Should have a .gitattributes file which effectively sets LF for git checkout. This has been the "new" system for 8 years now. No need for config changes at the local git install level.

SVN: Yes, might be a one-off pain to change the per-file SVN EOL config for WP core files, but it's basically the only one that's allowing CRLF.

@jrfnl jrfnl closed this as not planned Won't fix, can't repro, duplicate, stale Aug 15, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants