chore: every comment is two lines at most, checked against its code, and CI holds the rule (#288)
Merged
AL
3h ago+2443+2443+0123456789012345678901234567890123456789-5766-5766-0123456789012345678901234567890123456789
Closes #288.
Every comment in the code is now two lines at most, and each long one was read against the code beside it first. 273 files, 5,762 lines out and 2,432 in. No code changes.
The rule
A comment is two lines at most and says why (design/build.md, Comments).
- JSDoc: the description is two lines at most, and so is each tag's text. Every tag, type and name is kept: the plain-JS packages take their types from them. A type that runs over several lines is not counted.
- Kept whole: licence notices, and lines a tool reads (
@ts-expect-error,v8 ignore). - Skipped: vendored code, build output and hand-written
.d.tsfiles.
scripts/comments.mjs (pnpm comments) lists any comment past the limit, and CI's checks job runs it.
How it was checked
- A script compared every changed source file with
main, comments removed: 262 of 262 differ only in whole-line comments, and their JSDoc tags (tag, type, name) are the same in the same order. pnpm buildandpnpm typecheckpass.pnpm test:unitpasses: player 400, author 297, runtime 180, cmi5 50, normalize 35.- The generators (
sync:assets, the libraries'parts.mjs) write the same files as the ones committed.
Comments that were false, now true
- Downgrade. Three comments said content made for a newer library minor is refused; it plays at the newest older minor by default (
app.js,player-page.js,build-libraries.mjs). - h5p-standalone. Six comments in the worker and the element spoke of h5p-standalone resolving or probing; it has not run since the core was vendored (#37).
package-reader.ts: the reader does walk dependencies; text entries are inline before size is looked at.jobs-worker.ts: extraction uses the native codec, not zip.js.constants.ts: text entries are inline at any size, not only under 16 MB.source.ts:Last-Modifiedreads cross-origin withoutAccess-Control-Expose-Headers; onlyETagneeds it.h5p-offline-player.ts:runtimechecks three files, not four.content-types.yml: the sweep fails on a type that does not reachready, not on a missingfinished.- cmi5
client.ts: the learner preferences are read and passed on. scorm-browser.mjs: it builds 1.2 or 2004, not only 1.2.scorm-core.mjs: the runtime file list does hold the fonts' licence files.- Misplaced docs: five comments sat above the wrong declaration and are moved to the one they describe.
Things to know
- Reasons were cut, not moved. Where a long comment held several reasons, the one that explains the code stayed and some moved to a short comment at the line they explain. The rest are in git history, and the subagents' lists of the most valuable ones are kept for a later pass into
design/. packages/runtime/NOTICE.mdnow holds the list of where the content check departs from H5P's validator. The source comment held it, and the notice pointed there.- Generated files. Three generators had long comments in their templates (
sync-h5p-assets.mjs, the libraries'parts.mjs, the runtime'sbuild.mjs). The templates and the files they write changed together. - Shipped pages. Four comments inside the VS Code extension's page strings, and comments in
scorm.jsandresizer.js, are shorter. They are comments in files that ship; nothing that runs changed. - The element's doc comments are what an editor shows a user. Each keeps its meaning in two lines;
docs/api.mdhas the full text.
Summary by cubic
All comments are now at most two lines, each read against the code beside it first and corrected where it was false. 1,091 comments changed across 273 files; JSDoc tags and types stay identical, and the only code change is a CodeQL fix to the HTML filtering regexp.
The rule
- A comment is two lines and says why, documented in
design/build.md; licence notices and tool-read lines stay whole and types keep their tags, since the plain-JS packages take their types from them. scripts/comments.mjs(pnpm comments) lists any comment past the limit, and CI'schecksjob runs it.- Three generators' templates changed with the files they write, and
packages/runtime/NOTICE.mdnow holds the list of where the content check departs from H5P's validator, which the source comment used to.
Comments corrected
- Downgrade behavior, h5p-standalone, the package reader, cmi5 learner preferences and the SCORM runtime file list were wrong and are now true.
- Five comments sat above the wrong declaration and were moved to the one they describe.
- Three review passes restored facts the cut dropped, made further comments true, and closed the checker's gaps, a
/*after//among them; the last pass states what makes the faststart plan throw.