Config keys are hand-wired in five places with no completeness test

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

Los mantenedores suelen responder en 1 día

Nadie ha tomado este issue todavía.

Evaluación

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

Línea de trabajo

Start with internal/config/config.go and the hand-picked tests in internal/config/config_test.go; trace how Config fields are merged and classified by untrust. Add reflection coverage that exercises every leaf field and a table that states each field’s treatment for working-directory config. Run make test-short (or .\make.ps1 test-short on Windows) and check make lint; done when both completeness tests fail for omissions and existing config tests pass.

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

Descripción

help wanted severity: medium tech-debt

Summary

A setting has to be added to the struct, the defaults, merge, untrust, Validate and often the flag loader. Nothing ties these together, and two of the possible omissions fail silently.

Where

  • internal/config/config.go:424 (untrust)
  • internal/config/config.go:544 (merge)
  • internal/config/config.go:703 (Validate)
  • internal/cli/flags.go:133 (globalFlags.load)
  • internal/config/config_test.go:51, :134 (tests with hand-picked keys)

Details

merge only copies the fields it names (119 lines, one if per field), so a new struct field that TOML decodes, and that therefore passes the unknown-key check, is accepted and silently ignored unless it is also added to merge. untrust is a per-key list of what a spackle.toml found in the working directory may not set, so a new key gets no decision unless someone remembers to make one. The two tests that cover this set a hand-picked list of keys; neither walks the struct. No key was found to be wrong today; this is about the next one.

Impact

internal/config/config.go and docs/config.md are among the most frequently changed files, so keys are added often. Each addition is a five-place edit where an omission in merge or untrust produces no error and no failing test.

Suggested fix

Incremental, each step leaves behavior unchanged. (1) Add a test that walks Config with reflection, builds the dotted path of every leaf field, writes a file that sets each to a non-default value, loads it and asserts every leaf differs from the default; this pins merge. (2) Add a table that classifies every leaf path as kept, dropped or capped for a working-directory file, fail when a leaf is missing from the table, and assert untrust matches it. (3) Optionally replace the per-field chain in merge with a reflection overlay plus the few explicit exceptions, only after 1 and 2 are green.

Acceptance criteria

  • A reflection test fails when a struct field is not merged
  • A table test fails when a field has no stated treatment for a working-directory config file
  • Existing config tests still pass unchanged

Related: #112

Getting started

  • Relevant files: internal/cli/flags.go, internal/config/config.go, internal/config/config_test.go
  • How to run tests: make test-short (Unix) or .\make.ps1 test-short (Windows PowerShell); make lint before you call it done
  • Related docs: docs/config.md, CONTRIBUTING.md

Filed by repo-audit/full-audit at 50e92ec. Severity: medium. Effort: M. audit-key: tech-debt|internal/config/config.go|merge-completeness

Lenguaje dominante
Go
Estrellas
0
Forks
1
Merge medio
8 h 14 min
PR fusionados (30 d)
3

Preparar el entorno

Abrir en Codespaces

Inicia el contenedor de desarrollo del proyecto en tu navegador, con tu propia cuenta de GitHub.

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/Spackle

Todos los issues de TMHSDigital/Spackle

Issues similares

Más issues de Go

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.