Repository navigation
Closed
Labels
help wantedExtra attention is neededseverity: mediumEdge-case bugs, degraded behavior, meaningful maintenance costtech-debtRefactoring and maintainability
Description
Summary
Scan options are built by three separate hand-written literals (CLI, TUI and library). Some range checks sit outside the shared validator, the resolver pool is built three times, and defaults are duplicated. The front ends have already drifted: the TUI never sets AutoRate, RetryInconclusive, Deadline or TakeoverProviders, and nothing records whether that is intentional.
Where
- Three
scan.Options{...}builders:main.go:645-680(scanOptions),internal/tui/form.go:486-506(options),pkg/subenum/subenum.go:563-677(Config.options) - Checks outside
Options.Validate(internal/scan/options.go:50-73):- rate-per-resolver
< 0:main.go:350,internal/tui/form.go:425,pkg/subenum/subenum.go:578 MaxDuration:main.go:346,pkg/subenum/subenum.go:582
- rate-per-resolver
- Pool construction:
main.go:378-403,internal/tui/model.go:180-197,pkg/subenum/subenum.go:658-671 - Defaults:
main.go:221-243;internal/tui/form.go:83-105and:414;pkg/subenum/subenum.go:39-43 - Stats copies:
pkg/subenum/subenum.go:780-810(stats),main_resume.go:291-321(mergeStats)
Why it hurts now
Adding a scan setting means editing scan.Options, Options.Config, three builders, possibly three validators, and three copies of the defaults. Nothing fails if one is missed. -auto-rate already missed the TUI.
Plan (each step leaves the code green)
- Tests first:
- a reflection test per front end that sets every input and asserts each
scan.Optionsfield is populated or listed in a per-front-endunmappedallowlist with a reason (pattern:pkg/subenum/stats_test.go:39-60); - table tests that pin today's error messages for a negative rate-per-resolver and max-duration.
- a reflection test per front end that sets every input and asserts each
- Add
RatePerResolvertoscan.Options, move both range checks intoValidatewith{token}messages, and delete the ad-hoc checks. - Add one pool constructor (
dns.NewPoolFromLines(lines, timeout, perRes)) and call it from all three sites. - Add
scan.DefaultConcurrency,DefaultTimeoutMsandDefaultHitRate. Have the CLI flag defaults, the TUIdef:strings and the pkgDefault*constants refer to them. - Decide whether the TUI should expose
AutoRateandRetryInconclusive(see the TUI parity issue), or record the gap in the allowlist.
Getting started
- Relevant files: listed above
- How to run tests:
go test ./... - Related docs:
docs/ARCHITECTURE.md
Filed by repo-audit/full-audit at 3f671b2. Severity: medium. Effort: M. audit-key: tech-debt|internal/scan/options.go|Options-builders
Metadata
Metadata
Assignees
Labels
help wantedExtra attention is neededseverity: mediumEdge-case bugs, degraded behavior, meaningful maintenance costtech-debtRefactoring and maintainability
Activity
TMHSDigital commentedon Nov 14, 2026
Fixed in 4b22c95, following the plan:
TestScanOptionsSetsEveryField(CLI),TestOptionsSetsEveryFieldininternal/tuiand inpkg/subenum. Each fails when ascan.Optionsfield is left unset without a listed reason. Message pins:TestRangeErrorsNameFlags(CLI),TestRangeErrorsNameConfigFields(pkg), and the TUI'sTestResolverPoolField.scan.OptionshasRatePerResolverandMaxDuration.Validatechecks both, with a new{rate_per_resolver}setting, and the three ad-hoc checks are gone.dns.NewPoolFromLines(lines, timeout, perSecond)builds the pool at all three sites.scan.DefaultConcurrency,DefaultTimeoutMsandDefaultHitRatefeed the CLI flags and the TUI form.pkg/subenumkeeps its literalDefault*constants, so godoc shows plain values likeDefaultResolver, andTestDefaultsMatchTheCLIpins them to scan's.AutoRate,RetryInconclusive,MaxDuration/Deadlineas "no form field yet (TUI form lacks sources, max duration, auto rate, retry inconclusive, permute #274)", and the other gaps with their reasons.Verified with
go test ./..., golangci-lint v2.15.0 and gofmt. The stats copies (stats,mergeStats) listed under Where weren't part of the plan and are unchanged.