Skip to content

Clear the 482 inherited phpcs findings in lib/ - #2099

Closed
rubenvdlinde wants to merge 1 commit into
developmentfrom
fix/phpcs-inherited-482
Closed

rubenvdlinde wants to merge 1 commit into
developmentfrom
fix/phpcs-inherited-482

Conversation

@rubenvdlinde

Copy link
Copy Markdown
Contributor

What this does

integriq carried 482 phpcs errors on development. This clears all of them in the code. No baseline was regenerated, no suppression was added, and phpcs.xml is untouched.

They are ours: eleven PRs from this programme merged them to development before the integration branch existed, and every one reproduces against the programme base 778e2208.

Three categories

346 RequireNamedParameters. The sniff only fires on calls into our own code: $this->, self::/static::/parent::, and new OurClass(). Each one was rewritten by resolving the callee's real signature out of the AST, never from the parameter name a reader would guess. Five parent::__construct() calls into OCP\AppFramework\Controller needed the vendored stub parsed, because reflection cannot autoload it.

This is the category that bites. A named argument aimed at a name that does not exist is a fatal at runtime, and phpcs passes it happily. PHPStan and Psalm are the oracle, and both are clean.

116 DisallowInlineIf. Each ternary is hoisted into an if/else over a named local, or into a small private helper where the same shape repeated (requestOf, arrayOrEmpty, outcomeOf, describe). Nothing moved across a try boundary that could throw.

20 others. 17 ImplicitTrue, two inline comments starting lowercase, one line over 150 characters.

One near miss, now pinned

FileMigrationSource::read() builds its records from the mapping's kind, not from the $kind the caller asked to read. Hoisting ($mapping->getKind() ?: 'row') out of the call made the two trivially easy to swap, and the existing suite could not tell them apart: every test passed 'case' on both sides.

Two tests now separate them. Mutation checked: swapping the source of the value reddens assertSame('besluit', $records[0]->getKind()), not a setup line.

Verified locally

  • composer phpcs: 482 errors to 0, exit 0
  • vendor/bin/phpstan: no errors
  • vendor/bin/psalm: no errors
  • vendor/bin/phpunit: 3687 tests, 12606 assertions, all pass
  • composer phpmd: 123, unchanged from base. That pile is the next PR.

Inherited findings left alone

phpmd stays at 123 and check:schema-l10n stays over its baseline. Both get their own PR rather than riding along here.

🤖 Generated with Claude Code

Every one of these was already on development and reproduces against the
programme base 778e220. Three categories, all fixed in the code rather
than suppressed or baselined.

346 RequireNamedParameters. Rewritten by resolving each callee's real
signature from the AST, never from the parameter name a reader would
guess. The 5 parent::__construct() calls into OCP\AppFramework\Controller
were resolved by parsing the vendored stub, because reflection cannot
autoload it. PHPStan and Psalm are the oracle here: a named argument
aimed at a name that does not exist is a fatal at runtime and phpcs
passes it.

116 DisallowInlineIf. Each ternary is hoisted into an if/else over a
named local, or into a small private helper where the same shape
repeated. No behaviour moved across a try boundary that could throw.

20 others: ImplicitTrue, two lowercase inline comments and one line over
150 characters.

One of these was nearly a behaviour change. FileMigrationSource::read()
built its records from the mapping's own kind, not from the kind the
caller asked for, and hoisting the expression made the two easy to
confuse. Two tests now pin it: the existing suite could not tell them
apart because every case passed the same value on both sides.

Verified: phpcs 482 errors to 0, PHPStan clean, Psalm clean, 3687 tests
pass. phpmd is unchanged at 123, which is the next PR.

Refs the round 2 parity programme.
@rjzondervan

Copy link
Copy Markdown
Member

PR was superceded with fixes from #2065

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