Skip to content

Move CSL sanitization out of the root file (Phase B, ticket 5) - #160

Merged
dknauss merged 2 commits into
mainfrom
claude/keen-tesla-49orwb-edit-fields
Oct 21, 2026
Merged

dknauss merged 2 commits into
mainfrom
claude/keen-tesla-49orwb-edit-fields

Conversation

@dknauss

@dknauss dknauss commented Oct 21, 2026

Copy link
Copy Markdown
Owner

Summary

This is Phase B, ticket 5 of docs/planning/refactor-and-standards-memo.md, plus ticket 9 pulled forward.

  • The move. The 14 CSL-JSON validation and sanitization functions go from bibliography-builder.php to the new includes/csl-sanitize.php, unchanged and under the same names. Examples: bibliography_builder_get_known_csl_types(), …_sanitize_csl_date(), …_validate_and_sanitize_csl_item(). bibliography-builder.php drops from 2,213 to 1,592 lines; its only addition is one require_once.
  • Proof the moved text is unchanged: lines 425–1045 of the old root file are byte-identical to the new file after its 14-line header (checked with cmp).
  • Ticket 9 first, so it guards every later move.
    • tests/phpunit/FunctionInventoryTest.php checks the 255 bibliography_builder_* functions listed in tests/fixtures/function-inventory.txt (captured before any move).
    • It fails if any listed function is missing, or if any function is defined in more than one plugin file.
    • New functions don't need listing.
    • Mutation check: removing the new require_once makes the test fail, naming the missing functions.
  • Docs: CLAUDE.md, docs/current-metrics.md (line counts, the list of included files), and a progress table in the memo.

This touches the same root file as #158, but in different places, so the second to merge should merge cleanly. The metrics doc's list of included files will need a one-line merge.

Validation

  • composer lint:php, composer analyze:php: pass.
  • PHPUnit: 450 pass, including the new inventory test (3 tests).
  • npm run format:check, composer verify:metrics: pass.
  • npm run package:release: the ZIP includes includes/csl-sanitize.php, since packaging copies includes/ wholesale.

Checklist

  • No behavior change; function names unchanged
  • Tests added
  • Docs and metrics updated

Generated by Claude Code

The 14 CSL-JSON validation and sanitization functions move unchanged
from bibliography-builder.php to includes/csl-sanitize.php, under the
same names: the moved text is byte-identical to what was removed. The
root file goes from 2,213 to 1,592 lines.

Ticket 9 comes first so it guards this and every later move:
FunctionInventoryTest fails if any of the 255 functions listed in
tests/fixtures/function-inventory.txt is missing or defined in more
than one file. Removing the new require_once makes it fail, naming the
missing functions.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01KbVuMPN7YTcV27vwsG3LZ2
@codecov

codecov Bot commented Oct 21, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 94.31438% with 17 lines in your changes missing coverage. Please review.
✅ Project coverage is 88.27%. Comparing base (944f0bc) to head (a0bd8d7).
⚠️ Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
includes/csl-sanitize.php 94.31% 17 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff            @@
##               main     #160   +/-   ##
=========================================
  Coverage     88.27%   88.27%           
  Complexity       22       22           
=========================================
  Files            62       63    +1     
  Lines          7359     7359           
  Branches        699      699           
=========================================
  Hits           6496     6496           
  Misses          292      292           
  Partials        571      571           

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Resolves the metrics doc's list of included files (now twelve, with
csl-sanitize.php and email-output.php) and drops the two functions #158
deliberately removed, save_cite_export and save_export_link, from the
function inventory.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01KbVuMPN7YTcV27vwsG3LZ2
@dknauss
dknauss marked this pull request as ready for review October 21, 2026 18:54
@dknauss
dknauss merged commit 108763f into main Oct 21, 2026
19 checks passed
@dknauss
dknauss deleted the claude/keen-tesla-49orwb-edit-fields branch October 21, 2026 18:55
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