[wp-trac] [WordPress Trac] #49783: PHPCS config: Persistent caching on Travis

WordPress Trac noreply at wordpress.org
Wed Jun 3 23:00:37 UTC 2020


#49783: PHPCS config: Persistent caching on Travis
------------------------------+-------------------------------
 Reporter:  johnbillion       |       Owner:  (none)
     Type:  enhancement       |      Status:  new
 Priority:  normal            |   Milestone:  5.5
Component:  Build/Test Tools  |     Version:
 Severity:  normal            |  Resolution:
 Keywords:  has-patch         |     Focuses:  coding-standards
------------------------------+-------------------------------

Comment (by jrf):

 > I added that because `/phpcs.xml` was present in the `.gitignore`
 already and assumed this was desired and missed when I introduced the new
 `phpcompat.xml.dist` file. If this is an incorrect assumption, I can
 remove that from the diff.

 @desrosj Yes, that assumption is incorrect.

 To explain it: PHPCS will automatically pick up on a configuration file if
 it's called `[.]phpcs.xml[.dist]`. This means that if one of those file
 names is used, the user does not have to pass the `--standard=...`
 argument on the command-line.

 Between the different file names, there is precedence, with `.phpcs.xml`
 having the highest and `phpcs.xml.dist` the lowest.
 This allows for a project to have a `phpcs.xml.dist` file and an
 individual dev working on the project to have a local `phpcs.xml` file
 which will overrule the project file (but may include it) and will
 automatically be loaded as long as the `--standard=...` CLI argument is
 not used.
 Using this "trick", devs can, for instance, have stricter settings for
 themselves, test new rules before adding them or ignore a particular issue
 (like Windows line endings) etc.

 With that in mind, adding `phpcs.xml` and `.phpcs.xml` to the `.gitignore`
 file is best practice as that allows for devs using this automatic
 overload feature and prevents those local files from getting committed.

 The `phpcompat.xml.dist` file is not a standard file name PHPCS will pick
 up on, so it will always have to be passed as an argument on the command-
 line to be used.
 If a dev wants to locally overrule that file, they can name the local file
 whatever they want (safe for the above mentioned file names) as it won't
 get picked up automatically anyway and they will need to pass the filename
 of their local overload config file on the command-line via
 `--standard=...`.

 So, as there is no standard naming scheme for overloading the
 `phpcompat.xml.dist` file, adding an arbitrary name to the `.gitignore`,
 is, well, arbitrary, and this is probably better suited for the dev's own
 `.git/info/exclude` file.

 > What if the cache folder is added to the root and the tests/cache folder
 is removed in favor of that one? It would consolidate all cache files in
 one place and not cause confusion.

 All in favour of that. To make it obvious its a CI/dev directory and does
 not contain project files, you may want to consider naming the directory
 `/.cache/` as I suggested above.

-- 
Ticket URL: <https://core.trac.wordpress.org/ticket/49783#comment:11>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list