Skip to content

Hold changed lines and new files to the full WordPress standard#714

Open
obenland wants to merge 1 commit into
WordPress:trunkfrom
obenland:add-phpcs-clean-ruleset
Open

Hold changed lines and new files to the full WordPress standard#714
obenland wants to merge 1 commit into
WordPress:trunkfrom
obenland:add-phpcs-clean-ruleset

Conversation

@obenland

@obenland obenland commented Jul 16, 2026

Copy link
Copy Markdown
Member

Let's use WordPress as our coding standard. With AI writing most of our code now, it's trivial to have it conform new and updated code to the full standard, and everyone reading the code get to benefit from it.

What

Adds phpcs-clean.xml.dist — the stock WordPress coding standard with no sniff exclusions — and points the branch linter (.github/bin/phpcs-branch.php) at it. Newly written code is now held to the unmodified standard, while the existing tree is only ever checked on the lines a branch actually touches.

How it works

The linter already scopes itself to changed lines + new files:

  • Modified filesphpcs-changed, reporting only on lines the branch changed.
  • New files → full phpcs on the whole file.

Both paths now pass --standard=./phpcs-clean.xml.dist. Existing code is untouched until someone edits it.

Scope of each ruleset

File Standard Used by
phpcs.xml.dist WordPress + ~50 exclusions composer lint (whole repo) — unchanged
phpcs-clean.xml.dist Stock WordPress, no exclusions phpcs-branch.php (changed lines + new files)

phpcs-clean.xml.dist keeps only the environment config (minimum_wp_version, testVersion, PHPCompatibilityWP) and the shared file/vendor exclude-patterns.

Note

The stock WordPress.WP.Capabilities sniff is now active on changed code and will flag wporg-specific custom capabilities as unknown. When that happens, the cap gets documented in place rather than silenced:

<rule ref="WordPress.WP.Capabilities">
    <properties>
        <property name="custom_capabilities" type="array">
            <element value="plugin_admin_edit" />
        </property>
    </properties>
</rule>

Because this only fires on changed lines and new files, the list grows only with caps that actually touch new code.

🤖 Generated with Claude Code

https://claude.ai/code/session_0178d9rQN6YbCuz5LetN7Rzi

Add phpcs-clean.xml.dist: the stock WordPress coding standard with no
sniff exclusions, only the environment config (minimum_wp_version,
testVersion, PHPCompatibilityWP) and the shared file/vendor
exclude-patterns.

Point phpcs-branch.php at this ruleset for both the changed-lines path
(modified files) and the whole-file path (new files), so newly written
code is held to the unmodified standard while the existing tree is only
checked on the lines a branch actually touches.

phpcs.xml.dist is untouched and remains the lenient baseline for the
whole-repo `composer lint`.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_0178d9rQN6YbCuz5LetN7Rzi
Copilot AI review requested due to automatic review settings July 16, 2026 13:47

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@github-actions

Copy link
Copy Markdown

The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the props-bot label.

Core Committers: Use this line as a base for the props when committing in SVN:

Props obenland.

To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants