Repository navigation
feat: scope the PHPCS gate to the lines a change actually touches - #358
Merged
arifulhoque7 merged 3 commits intoSep 8, 2026
Merged
Conversation
PHPCS reports whole files. On a codebase with existing violations that means editing one line of a legacy file inherits every finding already in it, so the job is red no matter what the author does and people learn to ignore it. Measured on the Elementor widgets branch: the files it touches hold 175 security findings, but only 63 sit on lines it wrote. The other 112 are in Ajax.php, API.php and functions.php and predate the branch entirely. bin/phpcs-changed-lines.php reads the PHPCS JSON report, keeps only findings on added or modified lines, emits GitHub annotations for those, and exits non-zero if any survive. Claude-Session: https://claude.ai/code/session_019wvVjJ8agR8TWAVrrKVESH
Mirrors cs2pr --graceful-warnings, which the Dokan and WPUF workflows already use. Every finding on a changed line is still annotated; a warning no longer blocks the merge. Claude-Session: https://claude.ai/code/session_019wvVjJ8agR8TWAVrrKVESH
bin/phpcs-changed-lines.php is a CLI tool, not plugin runtime, so the WordPress sniffs for global prefixes, WP_Filesystem and system calls do not apply to it. The WPUF rulesets exclude their bin/ directory for the same reason. Claude-Session: https://claude.ai/code/session_019wvVjJ8agR8TWAVrrKVESH
arifulhoque7
added a commit
that referenced
this pull request
Sep 8, 2026
Brings in the line-scoped PHPCS gate (#358) and the bin/ exclusion. Claude-Session: https://claude.ai/code/session_019wvVjJ8agR8TWAVrrKVESH
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
PHPCS reports whole files. On a codebase that already has violations, that means editing one line of a legacy file inherits every finding already in it, so the job is red however careful the author is, and people learn to ignore it.
Measured on the Elementor widgets branch (wedocs-plugin#324), which touches 16 PHP files:
The other 112 sit in
Ajax.php,API.phpandfunctions.phpand predate the branch entirely. Asking a feature PR to fix core AJAX and REST paths it merely touched is the wrong trade: it bloats the diff, risks regressions, and makes review impossible.What this does
bin/phpcs-changed-lines.phpreads the PHPCS JSON report, keeps only findings that land on added or modified lines, emits a GitHub annotation for each, and sets the exit status.Only errors fail the run. Warnings are annotated but do not block, mirroring
cs2pr --graceful-warnings, which the Dokan and WPUF workflows already use.The base is
HEAD^1of the pull_request merge commit, which is the base branch tip, so the same commit the file list is already derived from.Effect
On #324, before its own fixes: 348 findings in the files, 106 on changed lines. That branch then closed all of its errors, and the gate passes there now.
Nothing about the ruleset changes. A file with pre-existing violations is still reported in full when you run
composer phpcslocally; this only decides what blocks a merge.Related: weDevsOfficial/plugin-internal-tasks#9
https://claude.ai/code/session_019wvVjJ8agR8TWAVrrKVESH