WordPress / WordPress/WordPress-Coding-Standards

"Hidden" standard with helper tools for WPCS maintainers

Open
#1,803 2 comments 7 reactions 1 assignee View on GitHub

@jrfnl is already working on this.

Since Jul 2, 2023.

Meta: Repo Type: Enhancement
Dominant language
PHP
Stars
2.8k
Forks
521
Avg merge
5d 20h
Merged PRs (30d)
1

Description

There are a number of lists in WPCS which should be updated on a regular basis - on every WP release - and gathering the information needed for this manually is a big maintenance burden.

Think:

  • List of WP native global variables - also see #924
  • List of deprecated hooks
  • List of deprecated functions
  • List of deprecated function arguments
  • List of all class names in the correct case
  • ... etc

It would be relatively easy to create a few sniffs which could be run over WP Core to gather this information.
Those sniffs however would have no value for the end-users of WPCS, only for WPCS developers.

So, what I'm proposing is as follows:

  • Add a new folder AnalyseWPCore with a ruleset.xml and sniff directory.
  • Add this folder to .gitattributes to be export-ignored. This way it will not be available in released versions of WPCS, but will only be available in git clones.
  • Over time add some custom sniffs to that directory which can gather the information we need to easily update the above mentioned lists.

Potentially future enhancements:

  • Add some custom reports which would pre-format the output of certain sniffs in a way that the output could just be copy/pasted into the right lists.
  • Add a bash script to run the reports in one go and potentially even update the lists in WPCS automatically.
  • Potentially run the reports via GH Actions on a cron schedule an automatically open an issue/PR/post to Slack when an update is needed.
    Note: we need to be careful about running against WP trunk though as we don't want WPCS to start flagging things which haven't been released et.

Opinions ?

FYI: I've already got a variation of the PrefixAllGlobals sniff ready for instance to allows us to update the global variables list easily.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.