【架构优化】拆分 scriptview.parseConfig 的模式校验、掩码列表校验并合并重复的排序比较函数

Đang mở
#440 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

@fx-kurumi đang làm issue này rồi.

Từ ngày 13/11/2026.

  • #442 của @fx-kurumi — đang mở

Đánh giá

Độ khó
3/5
Thời gian dự kiến
1-3 giờ
Mức phù hợp với người mới
25/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
tooling

Hướng nghiên cứu

Start with parseConfig in internal/scriptview/scriptview.go, where the mode checks, the masks/hide validation and the two slices.SortFunc comparators sit together. Extract the checks into the helper functions the issue names and merge the comparators, then confirm the existing TestConfig* and TestRefresh* tests still pass. Note that PR #442 is already open against this issue, so coordinate with it before starting a parallel change.

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

Mô tả

现状问题

internal/scriptview/scriptview.go 的 parseConfig 约 50 行,同时做了四件事:JSON 解码、执行/刷新模式校验与 argv 空字节检查、masks/hide 列表合法性与去重校验、两个列表的排序。其中两段 slices.SortFunc 的比较函数几乎一样(只是长度升序/降序相反),重复书写,阅读时不容易看出两者的差别。

重构方案

  • 拆出 validateConfigMode(config Config) error:刷新/执行两种模式的互斥校验 + argv 空字节检查;
  • 拆出 validateMaskLists(lists ...[]string) error:每个列表的 ValidMask 与去重检查;
  • 两处排序比较函数合并为 maskOrder(longestFirst bool) func(a, b string) int;
  • parseConfig 只保留解码与依次调用,错误文案、返回值、排序结果均保持不变。

影响范围

仅 internal/scriptview/scriptview.go 与对应测试文件,不改导出接口与行为。

验证方式

  • 现有 TestConfig* / TestRefresh* 测试全部通过;
  • 新增单测覆盖 maskOrder 的两种顺序(含同长度按字典序)和 validateMaskLists 的重复/非法项;
  • gofmt、go vet ./internal/scriptview/、go test ./internal/scriptview/ 通过。
Ngôn ngữ chính
Go
Star
141
Fork
28
Merge trung bình
1 ngày 15 giờ
Pull request đã merge (30 ngày)
113

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

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 Tencent/LoopForge

Tất cả issue của Tencent/LoopForge

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.