[wp-trac] [WordPress Trac] #47411: Build tools, WPCS: disable line ending check
WordPress Trac
noreply at wordpress.org
Thu Apr 9 00:54:56 UTC 2020
#47411: Build tools, WPCS: disable line ending check
------------------------------+-------------------------------
Reporter: azaozz | Owner: azaozz
Type: defect (bug) | Status: reopened
Priority: normal | Milestone: 5.5
Component: Build/Test Tools | Version:
Severity: normal | Resolution:
Keywords: has-patch commit | Focuses: coding-standards
------------------------------+-------------------------------
Comment (by GaryJ):
Replying to [comment:11 azaozz]:
> - With the default git settings line endings are controlled
automatically. It is not advisable to change the defaults unless all
contributors to a particular repository change their settings. In addition
these are "global" settings in git so requiring a contributor to change
them for one project is not a good idea.
Adding a `.gitattributes` file that defines `*.php` (and possibly others)
as `text` files (and therefore `LF` line endings) is all that's needed to
address that here. See https://adaptivepatchwork.com/2012/03/01/mind-the-
end-of-your-line/ or a newer article of your choosing. No global settings
changes needed at the local git config level.
> For svn:
> - This is somewhat more involved as @SergeyBiryukov mentions above.
"Line endings style" is a property of each file there. That property is
committed to the repository.
Subversion will store the file in the repository using normalized LF EOL
markers. So it seems like the presence of the `svn:eol-style` set to
`native` is the only thing that is allowing Windows users to have those
files converted to `CRLF`.
For Windows users using an editor that supports EditorConfig, then
[https://develop.svn.wordpress.org/trunk/.editorconfig this .editorconfig
file] will already be used to set line-endings to be LF.
That means that the per-file SVN eol-style property is directly
conflicting with the .editorconfig, and with pretty much the rest of the
PHP community who will be following code standards based off of PSR-2 /
PSR-12 which says to use LF.
> At this point I'm starting to wonder why WPCS is checking line endings
at all? Do we expect git and svn to be buggy and fail? How was this
handled before the had WPCS sniffs, were there any "line endings
accidents"?
Line-endings can be checked without version control being needed - PHPCS
setup for instant checks in an IDE when someone is working on a local
environment, for instance.
--
Ticket URL: <https://core.trac.wordpress.org/ticket/47411#comment:20>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list