[wp-trac] [WordPress Trac] #47411: Build tools, WPCS: disable line ending check
WordPress Trac
noreply at wordpress.org
Fri Sep 13 23:44:22 UTC 2019
#47411: Build tools, WPCS: disable line ending check
------------------------------+-------------------------------
Reporter: azaozz | Owner: azaozz
Type: defect (bug) | Status: reopened
Priority: normal | Milestone: 5.3
Component: Build/Test Tools | Version:
Severity: normal | Resolution:
Keywords: 2nd-opinion | Focuses: coding-standards
------------------------------+-------------------------------
Comment (by jrf):
I only just saw this ticket.
''**Please revert the committed patch as it is plain wrong.**''
I completely agree with what @johnbillion said above.
> Overriding it in core means core doesn't adhere to core's own coding
standards.
This is not an issue with WPCS or even the Core `phpcs.xml.dist` ruleset,
this is an issue with the setup as used by an individual developer.
There are two solutions for this - either one of which should be applied
by the individual developer -. Either solution will fix this, you only
need to choose which one you prefer to use.
This is not a Core issue.
**Solution 1: Set up git to check-out as-is.**
How git checks out files line-ending wise is a configuration setting of
the git install on the local machine.
By default, on Windows, it will check out files Windows-style and commit
Unix-style.
However, this can easily be changed to `check out as-is`. This is even one
of the questions during the normal git install procedure on Windows.
{{{
> git config --global core.autocrlf input
}}}
Ref: https://git-scm.com/book/en/v2/Customizing-Git-Git-Configuration -
section: Formatting and Whitespace
Same should be possible for SVN.
Alternatively, leave the settings as they are, git commit locally first
and only run PHPCS after that as the git commit will fix the line-endings
automatically.
**Solution 2: Locally overload the PHPCS configuration.**
The `phpcs.xml.dist` file are the project rules and should not be changed
for something like this.
However, if an individual dev wants to locally ignore certain issues (or
add extra rules) to facilitate their personal work-flow, that is perfectly
fine and PHPCS facilitates this easily.
Just add a `phpcs.xml` file to the root of your WP repo (no worries, that
file is git-ignored) with the following contents:
{{{
<?xml version="1.0"?>
<ruleset name="WP Core local">
<rule ref="./phpcs.xml.dist">
<exclude name="Generic.Files.LineEndings"/>
</rule>
</ruleset>
}}}
----
Other than that:
> as far as I see are not part of any (popular) coding standard.
I guess PSR2 and PSR12 are not popular coding standards in that case...
https://github.com/php-fig/fig-standards/blob/master/accepted/PSR-2
-coding-style-guide.md#22-files
> > Does this rule need to be fixed upstream in WPCS?
> No, it is not part of WPCS.
It **is** part of WPCS, but is not something which should be "fixed". It
is correct as it is.
----
Please feel free to ping me about issues like this in the future using my
handle. As Meta has not been sending mails for subscribed topics for ages,
I won't see it otherwise.
P.S.: You're not the only Windows based dev out there....
--
Ticket URL: <https://core.trac.wordpress.org/ticket/47411#comment:9>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list