Validation cleanups: library re-checks Options.Validate ranges; TUI labels drift

未关闭 适合新手
#414 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

维护者通常 1 天内回复

还没有人认领这个 Issue。

评估

难度
2/5
预计耗时
1-3 小时
新手友好度
78/100
Issue 类型
重构
描述清晰度
描述清楚
活跃度
活跃
技术栈
go
领域
cli, testing

调研方向

阅读 pkg/subenum/subenum.go 中的 Config.options 以及 internal/scan/options.go 中的 Options.Validate,然后检查 internal/tui/form.go 中的数值解析。添加建议的表格测试,并删除重复的库检查;更新 TUI 解析标签以使用 formFields。运行 go test ./pkg/subenum/ ./internal/tui/,并确认错误信息中包含 Config 字段名和屏幕上显示的标签。

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

描述

severity: low tech-debt

Summary

Two small validation cleanups:

  • The library's Config.options re-checks ranges that scan.Options.Validate already checks, and its wording has drifted.
  • The TUI's 154-line form.validate mixes hard-coded field labels with formFields names.

Where

  • pkg/subenum/subenum.go:619-641, 724-726; internal/scan/options.go:69-95
  • internal/tui/form.go:505-659 (in particular 569-584)

Details

  • Library. options() rejects Rate < 0, MaxQueries < 0, HitRate outside 1-100 and a bad resolver, then calls opts.Validate(), which checks the same four things with different text. Only the negative checks for Concurrency, Timeout, Attempts and Depth belong to the library, because 0 means "use the default" there. options.go:21-25 says the shared validator exists so that front ends "cannot drift apart in what they accept".
  • TUI. num(fieldConcurrency, "Concurrency"), "Timeout", "Attempts", "Hit rate", "Depth", "Rate" and "Max queries" are string literals, while the next line uses formFields[fieldRatePerResolver].name(). Renaming a form label leaves parse errors that name the old label.

Suggested fix

Each step is safe on its own:

  • Library:

    1. Table tests on Config.Validate for Rate=-1, MaxQueries=-1, HitRate=101 with Simulate, and a bad Resolver, asserting that the error names the Config field.
    2. Delete the four duplicated checks from options(). fieldNames already renders tokens as Config field names.
  • TUI:

    1. Make num(f) take its label from formFields[f].name().
    2. Optionally extract parseNumbers and parseLists helpers.

    Test first: a table test with one invalid value per numeric field, asserting the error names the field's on-screen label.

Acceptance criteria

  • One source of truth for the library's range checks
  • TUI parse errors use the on-screen field labels

Getting started

  • Relevant files: pkg/subenum/subenum.go, internal/scan/options.go, internal/tui/form.go
  • How to run tests: go test ./pkg/subenum/ ./internal/tui/
  • Related: #262, #331

Filed by repo-audit/full-audit at dd5b156. Severity: low. Effort: S. audit-key: tech-debt|pkg/subenum/subenum.go|Config.options

主要语言
Go
星标
1
派生
1
平均合并
7 小时 18 分钟
30 天内合并 PR
23

环境准备

在 Codespaces 中打开

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

从这里开始

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

TMHSDigital/subenum 的其他 Issue

查看 TMHSDigital/subenum 的全部 Issue

相似的 Issue

更多 Go Issue

把新 issue 发到你的邮箱

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