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

未关闭
#189 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

维护者通常 1 天内回复

还没有人认领这个 Issue。

评估

难度
4/5
预计耗时
3-5 天
新手友好度
58/100
Issue 类型
重构
描述清晰度
描述清楚
活跃度
活跃
技术栈
go
领域
backend

调研方向

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.

由索引模型根据 Issue 内容生成。

描述

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

主要语言
Go
星标
0
派生
1
平均合并
8 小时 14 分钟
30 天内合并 PR
3

环境准备

在 Codespaces 中打开

在浏览器里用你自己的 GitHub 账号启动这个项目的开发容器。

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

TMHSDigital/Spackle 的其他 Issue

查看 TMHSDigital/Spackle 的全部 Issue

相似的 Issue

更多 Go Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。