Skip to content

Remove dead code and fix undeclared dependencies - #1025

Open
Akshay-2007-1 wants to merge 1 commit into
source-academy:masterfrom
Akshay-2007-1:chore/modules-dead-code
Open

Akshay-2007-1 wants to merge 1 commit into
source-academy:masterfrom
Akshay-2007-1:chore/modules-dead-code

Conversation

@Akshay-2007-1

Copy link
Copy Markdown
Contributor

Part of source-academy/docs#42.

A dead-code pass with knip (configured for this monorepo's workspaces), each finding checked by hand and against the rest of the organisation. src/archive, src/java, devserver and the bundles that open pull requests change (repl, sound, torch, maze) are left alone.

Removed

  • lib/modules-lib/src/specialErrors.ts: interrupt() throwing 'source_academy_interrupt'. Nothing imports it, and a code search of the organisation finds the string only in this file. (It was reachable through modules-lib's ./* export and appeared in the generated docs.)
  • resolveAliasedSymbol in lib/lintplugin/src/rules/typed/utils.ts: no caller since throwRuntimeError stopped using it.
  • ParserSuccess and ParserError in lib/typedoc-plugin/src/json.ts: declared, never used.
  • Color and Numbers3 from the type re-export in src/tabs/Csg/src/jscad/types.ts: nothing imports them through the tab.

Unused dependencies (only comments mention them, or nothing at all): js-slang from bundles robot_simulation, csg and repeat; @sourceacademy/modules-lib from bundle repeat and tab RobotSimulation; @blueprintjs/core from tab Plotly; es-toolkit and gl-matrix from tab Rune; react-dom from tab Repeat. Bundles and tabs mark js-slang, react and Blueprint as external by name, so their builds do not depend on these entries.

Added (used but not declared)

  • lib/lintplugin: @typescript-eslint/type-utils (imported by throwRuntimeError.ts) and @types/estree (type import in regionComment.ts).
  • lib/vitest-reporter: @types/istanbul-lib-coverage (type import in coverage-reporter.cts).
    The lockfile reuses the versions already installed.

Checks

yarn constraints and yarn install --immutable pass. Typecheck, build and tests pass for every affected workspace (modules-lib, lint plugin, typedoc plugin, vitest reporter, bundles csg/repeat/robot_simulation, tabs Csg/Plotly/Rune/Repeat/RobotSimulation), and the 8 affected bundles and tabs build to the same output as on master. Three checks fail the same way on master and are not touched here: docs tsc (3 errors in .vitepress/config.ts), one lint error in lib/repotools/src/testing/__tests__/testing.test.ts, and the lint of bundles/robot_simulation.

Not included: unused exports of modules-lib (its exports are the documented API for bundle authors) and the unused export keywords on internal helpers.

Remove unused code (no references anywhere in the repository):
- lib/modules-lib/src/specialErrors.ts: interrupt() is never imported
- lib/lintplugin: unused resolveAliasedSymbol helper in rules/typed/utils.ts
- lib/typedoc-plugin: unused ParserSuccess and ParserError interfaces in json.ts
- tabs/Csg: drop the unused Color and Numbers3 re-exports from jscad/types.ts

Remove dependencies that are declared but never imported:
- bundles/robot_simulation: js-slang (only mentioned in comments)
- bundles/csg: js-slang (devDependency)
- bundles/repeat: @sourceacademy/modules-lib and js-slang (devDependency)
- tabs/RobotSimulation: @sourceacademy/modules-lib
- tabs/Plotly: @blueprintjs/core (only @blueprintjs/icons is used)
- tabs/Rune: es-toolkit and gl-matrix
- tabs/Repeat: react-dom

Declare dependencies that are imported but were missing:
- lib/lintplugin: @typescript-eslint/type-utils (imported by the
  throw-runtime-error rule) and @types/estree (used by regionComment.ts)
- lib/vitest-reporter: @types/istanbul-lib-coverage (used by the
  coverage reporter)

The lockfile only changes the affected workspace entries; the new
descriptors resolve to versions that were already locked. Built bundle
and tab outputs are byte-identical to master.

Part of source-academy/docs#42
@Akshay-2007-1

Copy link
Copy Markdown
Contributor Author

@codex review

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Dec 4, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-12-04T07:51:41.684942Z 7784092 Manual request
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Keep them coming!

Reviewed commit: 7784092162

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@Shrey5132 Shrey5132 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.

Checked the removed helpers/types and workspace dependencies against their imports, package exports, build configuration and lockfile; the newly declared type dependencies match actual imports. No blocking findings.

Validation: static source/reference and entry-point review plus the existing GitHub checks; I did not rerun this repository's build/test suite locally.

@AaravMalani AaravMalani left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

LGTM! Would it be possible to add the knip configuration to the repository as well and/or add it as a Yarn script for future reference?

This branch has not been deployed

No deployments
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.

3 participants