feat(NO-TASK): Share the branch-scoped coding-standards check - #50
Merged
Merged
Conversation
`linchpin/actions`' `php-checks.yml` runs `composer check-branch-cs`, so every repository calling that shared workflow has to provide it. Each one carried its own copy under `dev/Composer/Actions.php` — mantle and block-alchemy both did, and the two had already drifted. Discovery was about to add a third. One copy here, in a package all of them already require as a dev dependency, is one place to fix a bug in. Scoped to changed *lines* rather than changed files, which is the one behavioural difference from the copies it replaces. Sniffing each changed file whole is fine on a clean tree and wrong on any other: editing one line of a file carrying inherited findings reports all of them against the pull request that touched it, so the check fails for reasons its author did not cause and cannot fix in passing — and a gate like that gets switched off rather than fixed. On the repository this was written for, one such change reported 397 findings, of which 5 were on a line it had touched. `check_staged_cs` is new: the same filtering against a pre-commit diff, so a husky hook can catch a violation where it is cheapest to fix. It diffs the working tree against HEAD rather than the index, because lint-staged stashes unstaged work before running tasks and re-stages their modifications only after every task finishes — reading `--cached` reports the errors an autofixer task fixed a moment earlier. `run()` is public and takes plain arguments so it can be exercised without constructing a Composer event. Written to this package's PHP 8.0 floor rather than the callers' 8.4. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
aaronware
force-pushed
the
feat/NO-TASK/shared-branch-coding-standards
branch
from
September 12, 2026 15:24
742cbad to
b90e364
Compare
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.
linchpin/actions'php-checks.ymlrunscomposer check-branch-cs, so every repo calling that shared workflow must provide it. Each one has been carrying its own copy:Mantle\Dev\Composer\ActionsBlock_Alchemy\Dev\Composer\ActionsThe two that exist have already drifted from each other. All three — plus linchpin-blocks — already have
linchpin/coding-standardsinrequire-dev, so this is the obvious shared home. One copy, one place to fix a bug in.The one behavioural change
Scoped to changed lines rather than changed files.
Sniffing each changed file whole is fine on a clean tree and wrong on any other: editing one line of a file carrying inherited findings reports all of them against the PR that touched it. The check then fails for reasons its author did not cause and cannot fix in passing — and a gate like that gets switched off rather than fixed.
Concretely, on
linchpin/discovery: normalisingarray()→[]across twelve legacy files reported 397 findings, of which 5 were on a line the change had touched. It blocked its own formatting commit.The trade: a finding on an untouched line goes unreported until somebody edits that line. That's the intent — debt gets paid down by the changes passing through it.
Also new
check_staged_cs— the same filtering against a pre-commit diff, so a husky hook catches a violation where it's cheapest to fix. It diffs the working tree againstHEADrather than the index, because lint-staged stashes unstaged work before running tasks and re-stages their modifications only after every task finishes; reading--cachedreports the errors an autofixer task fixed a moment earlier.run()is public and takes plain arguments, so it can be exercised without constructing a Composer event.Written to this package's PHP 8.0 floor rather than the callers' 8.4.
Adopting it
Per repo, delete
dev/Composer/Actions.php, drop theautoload-deventry, and point the script at the shared class:linchpin/discoveryis ready to do that as soon as this releases.Two pre-existing observations, neither caused by this branch
Both reproduce on
mainwithout these changes. CI is green either way, so neither blocks this:composer validate --no-check-all --strictfails locally (Composer 2.10.2) withphp-parallel-lint/php-parallel-lintandphp-console-highlighterrequired but absent fromcomposer.lock. The same command passes in CI, so this looks like a Composer version difference rather than a broken lockfile — worth a look, since a localcomposer validateis what developers run before pushing.composer testerrors with 2 failures intests/FixtureTests.php(a PHPCSRuleseterror), onmainas well.🤖 Generated with Claude Code