config.js flags, storage keys and defaults are ignored by the code

未關閉
#29 0 則留言 0 個 reaction 已指派 0 人 在 GitHub 檢視

還沒有人認領這個 Issue。

評估

難度
4/5
預估耗時
3-5 天
新手友好度
55/100
Issue 類型
重構
描述清晰度
描述清楚
活躍度
活躍
技術堆疊
javascript

研究方向

Start with js/config.js, then trace the listed reads in js/game.js, js/main.js, js/utils.js, and js/board.js; review docs/ARCHITECTURE.md and .github/CONTRIBUTING.md for project conventions. Run npm test and npm run lint to establish the current behavior. Done when every config entry is used or removed, existing saved games still load through centralized storage keys, and no debug output appears with CONFIG.DEBUG false.

由索引模型根據 Issue 內容生成。

描述

severity: medium tech-debt

Summary

js/config.js is documented as the central configuration, but most of it is never read. Changing a flag or a storage key there changes nothing.

Where

  • js/config.js:8-53
  • js/game.js:45-48, js/game.js:91, js/game.js:671, js/game.js:682
  • js/main.js:19-22, js/main.js:68-70, js/main.js:89-90
  • js/utils.js:90-120, js/board.js:80

Details

  • FEATURES.UNDO_MOVE is false, yet undo is always wired and advertised.
  • STORAGE_KEYS defines staticChess.gameState and staticChess.settings; the code uses the literals chessGameState, showCoords, showPossibleMoves, showLastMove and enableSounds.
  • DEFAULT_SETTINGS, BOARD_SIZE, ANIMATIONS, GAME_TIMER and ADVANCED_DRAW_DETECTION are never read. The 300 ms animation is hard-coded at js/board.js:80.
  • FEATURES.SOUND_EFFECTS is overwritten at startup from the toggle.
  • initializeFeatureModules forces CONFIG.DEBUG = true during init, so debug lines print in production.
  • game.js logs with raw console.log on every move while drag.js uses debugLog.
  • saveToLocalStorage and loadFromLocalStorage have no callers.

Impact

Contributors following the docs flip flags that have no effect. Anyone who later adopts CONFIG.STORAGE_KEYS.GAME_STATE will orphan every saved game.

Suggested fix

  1. Add a save/load round-trip test for game state.
  2. Point CONFIG.STORAGE_KEYS at the keys in use today so no saved data is lost, then route game.js and main.js through the storage helpers.
  3. Read toggle defaults from DEFAULT_SETTINGS; use CONFIG.ANIMATIONS.PIECE_MOVE in board.js.
  4. Make UNDO_MOVE gate the button or delete it; delete flags with no code behind them.
  5. Remove the forced CONFIG.DEBUG = true and route logging through debugLog.

Each step leaves the app working and can be reviewed alone.

Acceptance criteria

  • Every entry in CONFIG is read somewhere, or removed
  • Storage keys come from one place and existing saved games still load
  • No debug output when CONFIG.DEBUG is false

Getting started

  • Relevant files: js/config.js, js/game.js, js/main.js, js/utils.js, js/board.js
  • How to run tests: npm install, then npm test and npm 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/config.js|CONFIG

主要語言
JavaScript
星號
4
分支
2
PR 合併指標
30 天內沒有已合併 PR

環境準備

從這裡開始

  1. 先讀完整個 Issue,再讀專案的貢獻指南。
  2. 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
  3. Fork 儲存庫,在一個分支上完成修改。
  4. 送出 Pull Request,並在描述裡引用這個 Issue 編號。

TMHSDigital/Static_Chess 的其他 Issue

查看 TMHSDigital/Static_Chess 的全部 Issue

相似的 Issue

更多 JavaScript Issue

把新 issue 寄到你的電子郵件信箱

精選適合新手參與的 GitHub issue 摘要。