Skip to content

PHPCS 3.3.2: add XSD schema to the rulesets #1477

Closed
@jrfnl

Description

@jrfnl

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

  • Add the XSD schema attributes to the various rulesets, like so:
    <ruleset name="My Project"
        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
        xsi:noNamespaceSchemaLocation="https://raw.githubusercontent.com/squizlabs/PHP_CodeSniffer/master/phpcs.xsd">
    Note: we can not use a relative schema location like ../vendor/squizlabs/php_codesniffer/phpcs.xsd as people are not required to install WPCS with Composer, let alone for it to be a project-based install, so we cannot rely on the xsd to be available in that location.
  • Validate the current rulesets against the schema and update them to comply if necessary.
  • Verify whether the Travis XML validation checks will take the newly added schema into account and if not, adjust them so they will.

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:

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions