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 摘要。