Skip to content

chore: sync canonical root configs + mechanical phpmd cleanup#228

Merged
rubenvdlinde merged 1 commit into
developmentfrom
chore/sync-canonical-root-configs
May 21, 2026
Merged

chore: sync canonical root configs + mechanical phpmd cleanup#228
rubenvdlinde merged 1 commit into
developmentfrom
chore/sync-canonical-root-configs

Conversation

@rubenvdlinde
Copy link
Copy Markdown
Contributor

Summary

Phase 2 fleet rollout for docudesk. Adopts the canonical root configs (phpcs/phpmd/psalm/phpstan) from nextcloud-app-template, then cleans the mechanical phpmd violations unmasked by the sync.

Pattern from shillinq#300 (merged) and decidesk#243 (merged).

Config changes

  • phpcs.xml: sync canonical (adds SpecTagSniff/NoLegacyServerAccessorsSniff wiring, ignore_warnings_on_exit, vendor-bin + lib/Resources/template excludes, lineLimit 150). Preserves DocuDesk description string.
  • phpmd.xml: byte-canonical (preserves DocuDesk ruleset name).
  • psalm.xml: sync canonical, plus 3 docudesk-specific referencedClass entries (OpenRegister EntityRelationMapper + RiskLevelService, thiagoalessio\TesseractOCR\TesseractOCR).
  • phpstan.neon: sync canonical (adds includes: phpstan-baseline.neon, broader Doctrine/OC/OCA/OCP stub-gap ignores, vendor-bin + lib/Resources/template excludes).
  • phpstan-baseline.neon: NEW. Captures the 15 tracked phpstan errors that remain after canonical sync (all "property never read, only written" on DI-injected services). Tracked in Lint debt cleanup post-canonical-sync (Phase 2 fleet rollout) #227 for source-level cleanup.
  • phpcs-custom-sniffs/.../SpecTagSniff.php + NoLegacyServerAccessorsSniff.php: NEW, copied from canonical.
  • phpstan-bootstrap.php: NEW, copied from canonical.

Source changes

49 mechanical phpmd fixes + 452 phpcbf auto-fixes across the lib/ tree:

  • 38 MissingImport: add use Exception; / use DateTimeImmutable; / use DateTimeInterface; / use RuntimeException; / use Imagick; / use OCP\Files\File; at the top of each file, replace \Foo references with the short name.
  • 5 ElseExpression: refactor into pre-assign default + conditional override (Ocr, EntityConsolidation, BatchAnonymizationController, SigningService x3).
  • 1 UnusedLocalVariable (preg_match_all 3rd-arg in SigningVerificationService): drop the out-parameter.
  • 1 UnusedLocalVariable ($userId in FileListingService): drop assignment, keep side-effecting auth-check call.
  • 3 UnusedFormalParameter/UnusedPrivateMethod: @SuppressWarnings on stable controller signatures + string-callable-referenced private methods.
  • 452 phpcbf auto-fixes: blank-line-between-function-defs style cleanup.

After this PR

phpmd has no native baseline file, so its CI gate stays red until #227 closes. This is the agreed-upon tracked-debt pattern for the fleet: per-app deviations are forbidden, but a tracked GitHub issue with a removal plan is acceptable.

Test plan

Refs #227

Phase 2 fleet rollout for docudesk. Drops per-app phpcs/phpmd/psalm/phpstan
extensions in favour of the canonical from nextcloud-app-template, then
cleans the mechanical phpmd violations unmasked by the sync.

Pattern from shillinq#300 and decidesk#243.

Config changes:
- phpcs.xml: sync canonical (adds SpecTagSniff/NoLegacyServerAccessorsSniff
  wiring, ignore_warnings_on_exit, vendor-bin + lib/Resources/template
  excludes, lineLimit 150). Preserves DocuDesk description string.
- phpmd.xml: byte-canonical (preserves DocuDesk ruleset name).
- psalm.xml: sync canonical (adds CalendarEventService + 16 other OCP/OR
  referencedClass entries fleetwide-promoted in nextcloud-app-template#49,
  plus docudesk-specific entries: OpenRegister EntityRelationMapper +
  RiskLevelService, thiagoalessio TesseractOCR).
- phpstan.neon: sync canonical (adds includes phpstan-baseline.neon,
  Doctrine\DBAL + broader OC\ + OCA\DAV\ + OCP stub-gap ignoreErrors,
  vendor-bin + lib/Resources/template excludePaths).
- phpstan-baseline.neon: NEW, captures the 15 tracked phpstan errors that
  remain after canonical sync - all tracked in #227 for source-level
  cleanup.
- phpcs-custom-sniffs/.../SpecTagSniff.php +
  phpcs-custom-sniffs/.../NoLegacyServerAccessorsSniff.php: NEW, copied
  from canonical so they can be referenced by the synced phpcs.xml.
- phpstan-bootstrap.php: NEW, copied from canonical.

Source changes - 49 mechanical phpmd fixes + 452 phpcbf auto-fixes:
- 38 MissingImport: add `use Exception;` / `use DateTimeImmutable;` /
  `use DateTimeInterface;` / `use RuntimeException;` / `use Imagick;` /
  `use OCP\Files\File;` at the top of each affected file and replace
  `\Foo` references with the short name.
- 5 ElseExpression: refactor `if/else` into pre-assign default +
  conditional override (preserves behaviour, no `else` keyword left) in
  OcrService, EntityConsolidationService, BatchAnonymizationController,
  SigningService (3 sites).
- 1 UnusedLocalVariable: drop the unused 3rd-arg out-parameter on
  preg_match_all() in SigningVerificationService.
- 1 UnusedLocalVariable: drop the assigned-but-unused $userId in
  FileListingService while keeping the side-effecting call (auth check).
- 3 UnusedFormalParameter / UnusedPrivateMethod: annotate with
  `@SuppressWarnings(PHPMD.UnusedFormalParameter)` /
  `@SuppressWarnings(PHPMD.UnusedPrivateMethod)` where the parameter is
  part of a stable controller signature or the method is referenced via
  string callable.
- 452 phpcbf auto-fixes: blank-line-between-function-defs style cleanup
  across the lib/ tree.

After this PR:
- phpcs: 0 violations (295 advisory @SPEC warnings, gated by
  ignore_warnings_on_exit).
- psalm: 0 errors.
- phpstan: 0 unmatched (15 baselined per #227).
- phpmd: 9 architectural violations remain (ShortVariable,
  TooManyPublicMethods, Cyclomatic/NPath complexity, CountInLoopExpression,
  CouplingBetweenObjects, Superglobals) - tracked in #227 for follow-up
  PRs.

phpmd does not support a native baseline file, so its CI gate stays red
until #227 closes. This is the agreed-upon tracked-debt pattern for the
fleet: per-app deviations are forbidden, but a tracked GitHub issue with
a removal plan is acceptable.

Refs: #227
@rubenvdlinde rubenvdlinde merged commit 1705ef5 into development May 21, 2026
10 of 13 checks passed
@rubenvdlinde rubenvdlinde deleted the chore/sync-canonical-root-configs branch May 21, 2026 20:43
@github-actions
Copy link
Copy Markdown
Contributor

Quality Report — ConductionNL/docudesk @ 13f470e

Check PHP Vue Security License Tests
lint
phpcs
phpmd
psalm
phpstan
phpmetrics
eslint
stylelint
composer ✅ 108/108
npm ✅ 575/575
PHPUnit ⏭️
Newman ⏭️
Playwright ⏭️

Quality workflow — 2026-05-21 20:45 UTC

Download the full PDF report from the workflow artifacts.

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.

1 participant