Skip to content

[ax] Add validate-config command for config hygiene checks - #8450

Merged
TomasVotruba merged 4 commits into
mainfrom
tv-validate-config
Sep 3, 2026
Merged

[ax] Add validate-config command for config hygiene checks#8450
TomasVotruba merged 4 commits into
mainfrom
tv-validate-config

Conversation

@TomasVotruba

Copy link
Copy Markdown
Member

Why

Agents and CI need a way to check a rector.php for hygiene problems without running a full refactor pass over the codebase. Until now these checks (deprecated rules, duplicate registrations, dead skips) only surfaced as warnings during a real process run, mixed in with the actual work.

What

New validate-config command. It boots the config, runs the existing hygiene reporters without touching any files, and exits non-zero if anything is reported - so it can gate CI or an agent step.

rector validate-config
# > [OK] Config is valid, no issues found        (exit 0)
# or
# > [WARNING] Registered rule "FooRector" is deprecated ...
# > [ERROR] 1 config issue found                 (exit 1)

Checks (all reuse existing services, no new detection logic):

  • deprecated registered rules, deprecated skipped rules
  • deprecated cache-meta extensions, php-sets methods, attributes-sets and composer-based args
  • rules using the deprecated beforeTraverse hook
  • skipped rules that were never registered, skipped classes that are not Rector rules
  • deprecated skipped classes
  • rules registered in both a set and withRules()

Implementation

  • The report* methods on DeprecatedRulesReporter and the two static checks on MissConfigurationReporter now return the number of issues reported (were void). ProcessCommand calls them as before and ignores the return, so behavior there is unchanged.
  • ValidateConfigCommand sums those counts plus the duplicate-registration and deprecated-skipped-class checks, and maps the total to SUCCESS/FAILURE.

Tests

  • ValidateConfigCommandTest: deprecated registered rule -> FAILURE; clean config -> SUCCESS (isolated reporters, exit code asserted via CommandTester).
  • composer check-cs, composer phpstan clean; existing MissConfigurationReporterTest still green; verified on the CLI.

@TomasVotruba TomasVotruba changed the title [Console] Add validate-config command for config hygiene checks [ax] Add validate-config command for config hygiene checks Sep 3, 2026
@TomasVotruba
TomasVotruba enabled auto-merge (squash) September 3, 2026 22:46
Fixes shared-process test isolation: other tests leak ROOT_STANDALONE_REGISTERED_RULES / SET_REGISTERED_RULES into the global param provider, which made getBothSetAndRulesDuplicatedRegistrations report a false issue.

Claude-Session: https://claude.ai/code/session_01QDEtmow9psVbccgbgHDqgd
…andTest setUp

Extend the clean baseline to every global param the hygiene reporters read, so no chunk order in the shared test process leaks a false issue into the JSON deprecated-rule count.

Claude-Session: https://claude.ai/code/session_01QDEtmow9psVbccgbgHDqgd
@TomasVotruba
TomasVotruba merged commit 136b25b into main Sep 3, 2026
43 checks passed
@TomasVotruba
TomasVotruba deleted the tv-validate-config branch September 3, 2026 22:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

1 participant