WPTT / WPThemeReview

PHP_CodeSniffer rules (sniffs) to enforce WordPress theme review coding conventions
MIT License
208 stars 38 forks source link

PHPCS 3.3.2: add XSD schema to ruleset #175

Closed jrfnl closed 5 years ago

jrfnl commented 6 years ago

Dependency Version

When the PHP_CodeSniffer dependency is at least version 3.3.2 (not yet released at the time of writing), then take the actions below.

Action checklist

Rationale:

An XSD schema definition file defines the expected format of an XML file. It defines the elements and attributes which can be used in the XML file and in which order those can be used.

Adding an XSD schema reference to an XML file will allow for stricter validation of the file to ensure it is valid for the purpose for which it is intended to be used, in this case: that it is a valid ruleset for use with PHPCS.

References:

jrfnl commented 5 years ago

For an example of how to implement this: https://github.com/squizlabs/PHP_CodeSniffer/pull/2187

dingo-d commented 5 years ago

Should we put this in 0.2.0 release or later?

jrfnl commented 5 years ago

I think it can be safely added now as long as the Travis check is added in a build against PHPCS master.

Note: since then one more oversight has been discovered in the PHPCS XSD file, but I don't think this will be a problem for TRTCS as I don't think that feature is used in the ruleset.

There is an open PR upstream to fix it which is expected to go into PHPCS 3.5.0: https://github.com/squizlabs/PHP_CodeSniffer/pull/2491

dingo-d commented 5 years ago

I'll tag this for later, as it's not a crucial feature for this release 🙂

jrfnl commented 5 years ago

As it is such a simple change which can contribute significantly to the QA, I've just pulled it now.