v3 Code Quality Review — Checklist

Status (2026-11-10): first tooling pass and all low-risk follow-ups done. Results and decisions: code_quality_review_findings_v1.md.

Merged so far: #139 (OpenPGP docs), #141 (this checklist + findings), #143 (RuntimeException import, escaped notices), #146 (dead code removed), #147 (high-traffic refresh bug), #148 (keep-notes, gpg status warning), #150 (git helpers take arrays), #151 (shared script helpers).

[x] done · [~] partly done or waiting on a decision (see the note) · [ ] not started

Scope: a dedicated pass over gulkily/v3 (snapshot cdec870, 2026-11-10) focused on dead code first and obvious quality issues second. Each item is a check to run; findings get logged in a results file before anything is deleted.

Codebase at a glance: ~426 PHP files in src/ForumRewrite (32 subsystems), 360 PHP test files, 66 scripts, ~85 JS assets, 42 CSS files, 516 plan docs.


Ground rules

Standing rules for every PR in this review; followed so far, so they stay unticked.

    • docs/plans/, including acceptance docs and runbooks. Some tools are documented only there (the Markdown audit scripts were).

    • scripts/README.md, which says what runs each script. ./v3 calls scripts by ${ROOT}/scripts/... path, so a bare file-name search misses them (the "one-time" migration scripts were live commands).

    • templates/, for classes and values used only from a template.

    • public/assets/*.PROVENANCE and code comments, for things kept on purpose (the OpenPGP source map).

    • git log -S<name>, to see whether a caller was removed on purpose and when.

    • Vendored third-party files get a <name>.PROVENANCE sidecar (upstream, version, integrity, SHA-256, modifications, why it's here, how to update) and a <name>.LICENSE. Examples: qrcode-generator.PROVENANCE, openpgp.PROVENANCE (PR #139).

    • First-party code that is only reached dynamically, or that is a deliberate twin, gets a short header comment saying what loads it and why.

    • When a finding turns out to be "keep", add the missing note in the same pass, so the next review doesn't trip over it again.


Part 1 — Dead code

1.1 PHP classes and methods

    • Activity/AccessHistoryPresenter — false positive, used from templates (access_history_event.php, paned_activity_item_row.php). Scans must include templates/.

  • [~] Unused use imports. Only in files touched by #146; those are cleaned up. Not swept repo-wide.

1.2 Feature flags

1.3 Routes, templates, assets

1.4 Scripts (scripts/, 66 files)

1.5 Repo clutter

1.6 Database / read model


Part 2 — Obvious quality issues

2.1 Oversized files (god classes)

  • [~] Methods over ~100 lines anywhere in src/. Measured: 32, led by the 1,083-line Application::handle (findings §6). Splitting is for separate Railspike cycles.

2.2 Duplication

  • [~] Copy-pasted logic between subsystems (signature checks, path building, timestamp formatting, HTML escaping, JSON response helpers). jscpd: 0.88% overall. Script helpers shared in #151; card partials and LLM providers left for their own cycles; toggle JS kept on purpose (findings §5).

  • [~] Server/browser rule pairs that must agree (e.g. UnicodeTextPolicy ↔ compose-time JS validator): are they generated from one source or hand-synced? Text rules: hand-synced; ASCII control gap fixed and UnicodeTextRuleParityTest added; Unicode version drift waits on a decision (findings, "Server and browser text rules"). Incremental updater vs full rebuild not started.

2.3 Error handling

  • [~] Functions that return false/null/'' for errors instead of throwing, with callers not checking. Write-side done: the unchecked purge journal writes are fixed (#162). Read-side needs a higher PHPStan level.

2.4 Security-adjacent quick checks

2.5 Type and API hygiene

2.6 Markers and comments

2.7 Tests


Tooling to set up first


Suggested order

  1. ~~Tooling + raw reports (no changes).~~ Done (#141).

  2. Repo clutter and obviously dead scripts/assets (lowest risk, quick wins). Not started: §1.4 and §1.5 need keep/remove decisions.

  3. Dead PHP classes/methods and stale feature flags. Dead members done (#146); test-only members and feature flags wait on decisions.

  4. ~~Error-handling and security quick checks (fix as found).~~ Done (#143, #148, #150).

  5. God-class splits — each as its own Railspike cycle, not part of this review.

Output