Regression: game.js still holds eight jobs in one 1,862-line scope
メンテナーはふだん 1 日以内に返信
まだ誰も着手していません。
評価
- 難易度
- 5/5
- 見積もり時間
- 1週間以上
- 初心者へのやさしさ
- 35/100
- issue の種類
- リファクタリング
- 明瞭さ
- おおむね明確
- 活発さ
- 活発
- 技術スタック
- javascript
- 領域
- backend
調査の方向性
Read js/game.js alongside js/notation.js, js/saved-game.js, and js/rules.js; start with the proposed playersFromPGN and replayUndoStack extractions and add direct unit tests for them. Then review statusForOutcome, describeMove, and the material count, using tests/helpers/load-game.js and npm test as described. Done means steps 1–4 are extracted, each extraction is committed separately, and the full suite passes after each.
索引モデルが issue の本文から書いたものです。
説明
Summary
#89 split some UI code out (game-ui.js), but js/game.js is still one 1,862-line script. It shares about 30 mutable top-level lets across eight jobs and is the most-changed file in the repo (74 of the last 200 commits). Several functions in it are pure, or close to pure, and can move out with little risk.
Where
js/game.js:6-56: live state, about 30letsjs/game.js:357-595: review and autoplayjs/game.js:1101-1215: clockjs/game.js:1345-1430: persistence and replayjs/game.js:1599-1764: PGN/FEN export and importjs/game.js:1766-1862: exports, including 15 getters only tests use
Details
The file's own section comments list its jobs: move flow, review and autoplay, ending a game without a move, the computer opponent, the clock, hints, persistence and replay, past games, view models, and PGN/FEN import and export.
Functions here that are pure or nearly pure:
replayUndoStack(start, moves, saved), around line 1400playersFromPGN(text), around line 1720statusForOutcome, around line 717- the material count in
updateCapturedDisplay, around lines 1496-1501 isThreefoldRepetition, around line 1293
Impact
Every recent feature (Redo, the Play button, random side, rebuilding the undo stack on load) had to edit this file and keep all of its globals in mind. Pure logic in it can only be tested by loading the whole page in jsdom (tests/helpers/load-game.js).
Suggested fix
Extract in small PRs, pure code first. Keep the old global name as a one-line alias until its callers move, so every PR leaves the page working.
- Move
playersFromPGNtonotation.js. - Move
replayUndoStacktosaved-game.jsorrules.js, asrebuildUndoStack(start, moves, savedKey). - Move
statusForOutcomeand the move sentence ofdescribeMoveinto a small text module, or intoreview.js. - Move the material count into
rules.jsasmaterialBalance(board). - Only then consider extracting the clock section behind an object that
game.jsowns.
Acceptance criteria
- Before starting: unit tests that call
replayUndoStackandplayersFromPGNdirectly, and characterization tests for thedescribeMovetext of castling, en passant, promotion and check. - Each extraction is its own commit, and the full suite passes after each one.
-
game.jsloses steps 1-4.
Getting started
- Relevant files:
js/game.js,js/notation.js,js/saved-game.js,js/rules.js,tests/helpers/load-game.js - How to run tests:
npm test
Regression of #89.
Filed by repo-audit/full-audit at 01c6a35. Severity: medium. Effort: L. audit-key: tech-debt|js/game.js|module-structure
- 主要言語
- JavaScript
- スター
- 4
- フォーク
- 2
- 平均マージ
- 22時間 16分
- マージ済み PR(30日)
- 9
環境構築
- Dockerfile・Docker Compose ファイルなし
- プルリクエストのテンプレートあり
- コントリビューションガイドを読む
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
TMHSDigital/Static_Chess のほかの issue
-
enhancement help wanted severity: low
難易度 4/5 3〜5日 初心者へのやさしさ 55/100
TMHSDigital/Static_Chess#184 ·
メンテナーはふだん 1 日以内に返信
-
enhancement help wanted severity: low
難易度 4/5 3〜5日 初心者へのやさしさ 58/100
TMHSDigital/Static_Chess#182 ·
メンテナーはふだん 1 日以内に返信
-
help wanted severity: medium tech-debt
難易度 4/5 3〜5日 初心者へのやさしさ 45/100
TMHSDigital/Static_Chess#173 ·
メンテナーはふだん 1 日以内に返信
-
help wanted performance severity: medium
難易度 5/5 1週間以上 初心者へのやさしさ 38/100
TMHSDigital/Static_Chess#168 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
-
enhancement help wanted severity: low
難易度 4/5 3〜5日 初心者へのやさしさ 61/100
TMHSDigital/Static_Chess#161 ·
メンテナーはふだん 1 日以内に返信
TMHSDigital/Static_Chess の issue をすべて見る
似ている issue
-
priority: low server testing
難易度 1/5 1時間未満 初心者へのやさしさ 88/100
blamechris/chroxy#9277 ·
メンテナーはふだん 1 日以内に返信
-
[MCP]: page snapshots in .playwright-mcp/ are not git-ignored (.playwright-cli/ is, since #42318)オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 62/100
microsoft/playwright#44289 ·
メンテナーはふだん 1 日以内に返信
-
Bug
難易度 2/5 1〜3時間 初心者へのやさしさ 75/100
Ionaru/easy-markdown-editor#657 ·
-
難易度 2/5 1〜3時間 初心者へのやさしさ 66/100
TMHSDigital/Free-Game-Dev-Assets#320 ·
メンテナーはふだん 1 日以内に返信
-
area:webapp bug finding
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
メンテナーはふだん 1 日以内に返信