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

Đang mở Phù hợp với người mới
#414 0 bình luận 0 reaction 0 người được giao Xem trên GitHub

Maintainer thường phản hồi trong vòng 1 ngày

Chưa có ai nhận issue này.

Đánh giá

Độ khó
2/5
Thời gian dự kiến
1-3 giờ
Mức phù hợp với người mới
78/100
Loại issue
Tái cấu trúc
Độ rõ ràng
Đặc tả rõ ràng
Mức độ hoạt động
Sôi nổi
Công nghệ
go
Lĩnh vực
cli, testing

Hướng nghiên cứu

Đọc Config.options trong pkg/subenum/subenum.go cùng với Options.Validate trong internal/scan/options.go, sau đó kiểm tra việc phân tích số trong internal/tui/form.go. Thêm các kiểm thử dạng bảng được đề xuất và xóa các kiểm tra thư viện bị trùng lặp; cập nhật nhãn phân tích của TUI để dùng formFields. Chạy go test ./pkg/subenum/ ./internal/tui/ và xác nhận các lỗi nêu tên các trường Config và nhãn hiển thị trên màn hình.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

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

Ngôn ngữ chính
Go
Star
1
Fork
1
Merge trung bình
7 giờ 18 phút
Pull request đã merge (30 ngày)
23

Chuẩn bị môi trường

Mở trong Codespaces

Khởi chạy dev container của dự án ngay trên trình duyệt, bằng tài khoản GitHub của bạn.

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của TMHSDigital/subenum

Tất cả issue của TMHSDigital/subenum

Issue tương tự

Thêm issue về Go

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.