Skip to content

Lint debt cleanup post-canonical-sync (Phase 2 fleet rollout) #1640

@rubenvdlinde

Description

@rubenvdlinde

Follow-up cleanup tracking issue created during the Phase 2 fleet root-config consolidation sync ("chore: sync canonical root configs + mechanical phpmd cleanup").

Pattern matches ConductionNL/shillinq#299 and ConductionNL/decidesk#243. openregister is the foundation app — largest follow-up scope across the fleet.

Quality gate state after sync + mechanical fixes

  • phpcs: 336 errors, 3594 warnings remain (auto-fix already ran)
  • phpstan: 0 unmatched errors, 1724 baselined entries (phpstan-baseline.neon)
  • psalm: 145 unbaselined errors surfaced — existing psalm-baseline.xml preserved untouched per fleet plan
  • phpmd: 59 architectural violations remain (mechanical categories cleared)

Phase-2 mechanical fixes already applied in this PR

  • MissingImport: 57 → 0 (added 25+ use statements across Application.php, BookmarksProvider, CalendarProvider, TasksProvider, ExternalIntegrationRouter, ResponseGenerationHandler, ObjectService, PdfReportWriter, UserService)
  • ElseExpression: 15 → 0 (refactored to early-return / continue / default-then-override patterns)
  • UnusedFormalParameter: 7 → 0 (added @SuppressWarnings(PHPMD.UnusedFormalParameter) on deprecated facade signatures with TODO comments)
  • UnusedLocalVariable: 2 → 0 (renamed to $_ + suppression annotation)
  • BooleanArgumentFlag: 2 → 0 (suppressed on requestHeaders($withBody) — body-vs-no-body is the natural HTTP-headers toggle)

Total mechanical fixes: ~80 violations cleared.

phpcs follow-up debt (336 errors / 3594 warnings)

  • CustomSn.Commenting.SpecTag missing method spec: 2793 — ADR-008 @spec tag missing on per-method docblocks across lib/
  • CustomSn.Commenting.SpecTag missing class spec: 801 — same, class-level
  • Squiz.PHP.DisallowInlineIf: 309 ternaries flagged (~/2 line refactors each, mostly readable already)
  • A handful of Squiz.Whitespace.FunctionSpacing and Generic.WhiteSpace.ScopeIndent corner cases the auto-fixer can't resolve.

phpstan baselined debt (1724 entries — top categories)

  • Magic method Entity::get*()/set*(): Register/Schema/ObjectEntity/Organisation entity getters not declared as @method docblocks → add explicit annotations.
  • find() / findAll() signature drift across mappers: extra args like uuid/slug/_multitenancy/_rbac not on the QBMapper parent contract → unify the mapper contract.
  • LLPhant dynamic-property access: $config->temperature = … etc. — vendor doesn't declare these, wrap in a typed adapter or pin a vendor patch.
  • Cron\\CronExpression / Sabre\\VObject\\*: vendor noise from runtime-only deps, acceptable to allowlist.
  • AppendOnlyException, AuthorizedAdminSetting: real type drift, fix in code.

psalm follow-up debt (145 unbaselined errors)

The canonical psalm.xml is stricter than the prior per-app one — most new errors fall in:

  • TooFewArguments on BuiltinProviders\TasksProvider::__construct (DI wiring lost args after refactor — real bug)
  • InvalidTemplateParam on JSONResponse<int, …> — Nextcloud OCP's S template restricts to specific HTTP status ints; controllers pass int widening
  • UndefinedClass: OC\\Security\\CSP\\ContentSecurityPolicyNonceManager / CSRF\\CsrfTokenManager in GraphQLController — internal OC namespace, suppress per-file
  • Various MissingPropertyType / MissingClosureReturnType — annotate as encountered

phpmd architectural debt (59 remaining)

All categories are architectural (refactor required):

  • 13 CyclomaticComplexity, 10 NPathComplexity, 4 ExcessiveMethodLength, 4 CouplingBetweenObjects (AuditTrailMapper, ConfigurationSettingsHandler, Application::registerIntegrationRegistry — the usual suspects)
  • 7 StaticAccess (\\OC::$server access points to migrate; ADR forbids new uses, kept for legacy bootstrapping)
  • 7 IfStatementAssignment (assignment-in-if pattern — refactor for clarity)
  • 5 LongVariable, 2 TooManyMethods, 2 ExcessiveClassComplexity, 2 ErrorControlOperator (@-suppression), 2 TooManyPublicMethods, 1 NumberOfChildren, 1 ExitExpression, 1 ExcessiveClassLength

Next steps (priorities)

  • Add @method docblocks to Register, Schema, ObjectEntity, Organisation entities — likely clears 200+ phpstan baseline entries
  • Wrap LLPhant config in typed adapter — clears ~6 psalm suppressions + N phpstan entries
  • Unify mapper find() / findAll() signatures across registers/schemas/objects/audit-trail mappers
  • Refactor BuiltinProviders\TasksProvider::__construct to fix the real psalm TooFewArguments finding
  • Re-author AuditTrailMapper, ConfigurationSettingsHandler::*, Application::registerIntegrationRegistry over multiple smaller helpers
  • Fill in ADR-008 @spec tags on the 800 classes / 2800 methods that drive the phpcs warning volume (likely the longest-tail item)

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions