Remove dead and duplicated code that has drifted from the live paths
還沒有人認領這個 Issue。
評估
- 難度
- 4/5
- 預估耗時
- 3-5 天
- 新手友好度
- 45/100
- Issue 類型
- 重構
- 描述清晰度
- 描述清楚
- 活躍度
- 活躍
- 技術堆疊
- eslint, html, javascript
研究方向
Start with docs/ARCHITECTURE.md and .github/CONTRIBUTING.md, then inspect the listed functions in js/game.js, js/utils.js, and js/board.js, along with eslint.config.js, .eslintrc.cjs, and package.json. Run npm test and npm run lint after installing dependencies. Done means the listed duplicate and unused code is resolved, SAN disambiguation considers all candidates, and lint and tests pass.
由索引模型根據 Issue 內容生成。
描述
Summary
Several functions and files are unused or duplicated, and the copies no longer agree. The unused copies are the ones a contributor is likely to find first and edit.
Where
js/game.js:800-840(generateNotation, unused),js/utils.js:132-173(formatSAN, unused),js/game.js:845-906(the live formatter)js/game.js:472-487,js/game.js:525-540,js/game.js:865-874(three copies of the path-obstruction walk)js/game.js:561-574(isKingInCheckandisKingInCheckWithPositions)js/game.js:363-378(pawn guards that cannot fire) andjs/game.js:386-394(en passant added again)js/board.js:210-219(delegateBoardClick, unused)js/utils.js:206-208(getOppositeColor, unused while the same expression is inlined six times ingame.js)js/ai.js,js/promotion.js(not loaded byindex.html:65-71;js/main.js:100-110checks for them).eslintrc.cjs,package.json:15(eslint-config-prettier)
Details
formatSANreadsmove.isCaptureandmove.isKingsideCastling, fieldsmakeMovenever sets.ChessAI._getAllLegalMovesreturns[], sofindBestMovealways resolvesnull.- ESLint 9 reads
eslint.config.jsand ignores.eslintrc.cjs. That legacy file extendsplugin:prettier/recommended, a plugin that is not a dependency, andeslint-config-prettieris declared but never imported. - SAN disambiguation keeps the last matching piece instead of considering all candidates (
js/game.js:878-882): with white rooks on a1, a5 and h3, Ra1-a3 is writtenRa1a3instead ofR1a3.
Impact
A notation or rules fix has several candidate places and most do nothing. Two ESLint configs with different settings invite edits to the wrong one.
Suggested fix
Small changes, each reviewable alone, with SAN tests added first:
- Delete
generateNotationandformatSAN - Give
isPathObstructeda board parameter and delete the other two copies - Fold
isKingInCheckWithPositionsintoisKingInCheck - Keep one en passant branch and delete the unreachable pawn guards
- Delete
delegateBoardClick; use or deletegetOppositeColor - Delete
.eslintrc.cjs; removeeslint-config-prettieror import it as the last entry ofeslint.config.js - Mark
ai.jsandpromotion.jsas not shipped, or remove them until the features are built - Compute SAN disambiguation over all candidate pieces
Acceptance criteria
- No unused exported functions remain in
js/ - One ESLint config
- Lint and tests pass
Getting started
- Relevant files:
js/game.js,js/utils.js,js/board.js,js/ai.js,js/promotion.js,.eslintrc.cjs,package.json - How to run tests:
npm install, thennpm testandnpm run lint - Related docs:
docs/ARCHITECTURE.md,.github/CONTRIBUTING.md
Filed by repo-audit/full-audit at 8a2c86c. Severity: medium. Effort: M. audit-key: tech-debt|js/game.js|generateNotation
- 主要語言
- JavaScript
- 星號
- 4
- 分支
- 2
- PR 合併指標
- 30 天內沒有已合併 PR
環境準備
- 沒有 Dockerfile 或 Docker Compose 檔案
- 有 Pull Request 範本
- 閱讀貢獻指南
從這裡開始
- 先讀完整個 Issue,再讀專案的貢獻指南。
- 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
- Fork 儲存庫,在一個分支上完成修改。
- 送出 Pull Request,並在描述裡引用這個 Issue 編號。
TMHSDigital/Static_Chess 的其他 Issue
-
enhancement good first issue severity: medium
難度 2/5 1-3 小時 新手友好度 78/100
TMHSDigital/Static_Chess#53 ·
-
documentation good first issue severity: low
難度 2/5 1-3 小時 新手友好度 72/100
TMHSDigital/Static_Chess#49 ·
-
documentation good first issue severity: low
難度 2/5 1-3 小時 新手友好度 83/100
TMHSDigital/Static_Chess#48 ·
-
documentation severity: medium
難度 2/5 1-3 小時 新手友好度 78/100
TMHSDigital/Static_Chess#47 ·
-
documentation good first issue severity: low
難度 2/5 1-3 小時 新手友好度 82/100
TMHSDigital/Static_Chess#46 ·
查看 TMHSDigital/Static_Chess 的全部 Issue
相似的 Issue
-
good first issue tests
難度 1/5 1-3 小時 新手友好度 68/100
維護者通常 1 天內回覆
-
enhancement good first issue
難度 2/5 1-3 小時 新手友好度 90/100
-
1️⃣ phase/under-investigation flaky/confirmed flaky/needs-decision type/bug
難度 2/5 1-3 小時 新手友好度 65/100
growilabs/growi#12246 · 3 則留言 ·
維護者通常 1 天內回覆
-
難度 1/5 1 小時以內 新手友好度 72/100
TMHSDigital/Free-Game-Dev-Assets#301 ·
維護者通常 1 天內回覆
-
難度 2/5 1-3 小時 新手友好度 79/100