Remove dead and duplicated code that has drifted from the live paths

Abierto
#30 0 comentarios 0 reacciones 0 asignados Ver en GitHub

Nadie ha tomado este issue todavía.

Evaluación

Dificultad
4/5
Tiempo estimado
3-5 días
Aptitud para principiantes
45/100
Tipo de issue
Refactorización
Claridad
Bien especificado
Estado de actividad
Activo
Stack tecnológico
eslint, html, javascript
Área
backend, testing

Línea de trabajo

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.

Escrito por el modelo de indexación a partir del texto del issue.

Descripción

severity: medium tech-debt

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 (isKingInCheck and isKingInCheckWithPositions)
  • js/game.js:363-378 (pawn guards that cannot fire) and js/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 in game.js)
  • js/ai.js, js/promotion.js (not loaded by index.html:65-71; js/main.js:100-110 checks for them)
  • .eslintrc.cjs, package.json:15 (eslint-config-prettier)

Details

  • formatSAN reads move.isCapture and move.isKingsideCastling, fields makeMove never sets.
  • ChessAI._getAllLegalMoves returns [], so findBestMove always resolves null.
  • ESLint 9 reads eslint.config.js and ignores .eslintrc.cjs. That legacy file extends plugin:prettier/recommended, a plugin that is not a dependency, and eslint-config-prettier is 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 written Ra1a3 instead of R1a3.

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 generateNotation and formatSAN
  • Give isPathObstructed a board parameter and delete the other two copies
  • Fold isKingInCheckWithPositions into isKingInCheck
  • Keep one en passant branch and delete the unreachable pawn guards
  • Delete delegateBoardClick; use or delete getOppositeColor
  • Delete .eslintrc.cjs; remove eslint-config-prettier or import it as the last entry of eslint.config.js
  • Mark ai.js and promotion.js as 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, 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/game.js|generateNotation

Lenguaje dominante
JavaScript
Estrellas
4
Forks
2
Métricas de merge de PR
Sin PR fusionados en 30 d

Preparar el entorno

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Más de TMHSDigital/Static_Chess

Todos los issues de TMHSDigital/Static_Chess

Issues similares

Más issues de JavaScript

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.