Skip to content

chore: every comment is two lines at most, checked against its code, and CI holds the rule (#288) - #292

Merged
alekswebnet merged 5 commits into
mainfrom
chore/short-comments
Nov 26, 2026
Merged

alekswebnet merged 5 commits into
mainfrom
chore/short-comments

Conversation

@alekswebnet

@alekswebnet alekswebnet commented Nov 26, 2026 •

Copy link
Copy Markdown
Contributor

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.ts files.

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 build and pnpm typecheck pass.
  • pnpm test:unit passes: 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 (Vendor the H5P core from h5p-php-library and retire h5p-standalone #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-Modified reads cross-origin without Access-Control-Expose-Headers; only ETag needs it.
  • h5p-offline-player.ts: runtime checks three files, not four.
  • content-types.yml: the sweep fails on a type that does not reach ready, not on a missing finished.
  • 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.md now 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's build.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.js and resizer.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.md has 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's checks job runs it.
  • Three generators' templates changed with the files they write, and packages/runtime/NOTICE.md now 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.

Written for commit 8f32713. Summary will update on new commits.

View guided diff Turn on auto-fix

…and CI holds the rule (#288)

1,091 comments ran past two lines, 5,400 lines in all. Each was read
against the code beside it, made true where it was not, and cut to the
reason. No code changes: every changed source file differs from before
only in whole-line comments, and the JSDoc tags and their types are the
same.

scripts/comments.mjs (pnpm comments) lists any comment past the limit,
CI's checks job runs it, and design/build.md has the rule. Three
generators write shorter comments into the files they make, and the
runtime's NOTICE.md takes over the list of where the content check
departs from H5P's, which its source comment held.
Comment thread scripts/comments.mjs Fixed
…egexp'

Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>

@cubic-dev-ai cubic-dev-ai Bot left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All reported issues were addressed

Note: This PR contains a large number of files. cubic selects up to 200 of the highest-priority eligible files for this review, so some files may not have been reviewed.

View guided diff | Turn on auto-fix | Re-trigger cubic

Comment thread scripts/comments.mjs Resolved
Comment thread packages/player/src/shared/revision.ts Resolved
Comment thread packages/cmi5/src/index.ts Resolved
Comment thread packages/author/lib/types.mjs Resolved
Comment thread packages/author/lib/generator.mjs Resolved
Comment thread packages/player/src/sw/mount.ts Resolved
Comment thread packages/author/lib/schema.mjs Resolved
Comment thread packages/vscode/scripts/package.mjs Resolved
Comment thread design/build.md Resolved
Comment thread packages/cmi5/src/index.ts Resolved

@cubic-dev-ai cubic-dev-ai Bot left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All reported issues were addressed across 273 files

Note: This PR contains a large number of files. cubic selects up to 200 of the highest-priority eligible files for this review, so some files may not have been reviewed.
Requires human review: Auto-approval blocked because this review re-detected 22 unresolved issues already reported by Cubic.

View guided diff | Turn on auto-fix | Re-trigger cubic

Comment thread packages/embed/lib/scorm-browser.mjs Resolved
Comment thread packages/cmi5/src/index.ts Resolved
Comment thread packages/author/tests/bundle.test.ts Resolved
Comment thread api/no-range.js Resolved
Comment thread scripts/comments.mjs Resolved
Comment thread packages/author/tests/names.test.ts Resolved
Comment thread packages/author/tests/helpers/mp4.ts Resolved
Comment thread apps/demo/demo/theme.js Resolved
Comment thread packages/player/src/sw/sw-entry.ts Resolved
Comment thread packages/normalize/lib/mp4.mjs Resolved
…ped, a few comments made true, the checker's gaps)

@cubic-dev-ai cubic-dev-ai Bot left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All reported issues were addressed across 79 files (changes from recent commits).

Reply with feedback, questions, or to request a fix.

View guided diff | Turn on auto-fix | Re-trigger cubic

Comment thread packages/player/src/shared/range.ts Resolved
Comment thread scripts/comments.mjs Resolved
Comment thread packages/normalize/lib/mp4.mjs Resolved
Comment thread packages/author/lib/media.mjs Resolved
Comment thread packages/author/lib/generator.mjs Resolved
…t the first 100, a /* after // in the checker)

@cubic-dev-ai cubic-dev-ai Bot left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All reported issues were addressed across 23 files (changes from recent commits).

Reply with feedback, questions, or to request a fix.

View guided diff | Turn on auto-fix | Re-trigger cubic

Comment thread packages/normalize/lib/mp4.mjs Resolved
@alekswebnet
alekswebnet merged commit 94dd853 into main Nov 26, 2026
14 checks passed
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.

Comments: two lines at most, checked in CI

2 participants