【架构优化】拆分 scriptview.parseConfig 的模式校验、掩码列表校验并合并重复的排序比较函数
维护者通常 1 天内回复
评估
调研方向
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.
由索引模型根据 Issue 内容生成。
描述
现状问题
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/通过。
- 主要语言
- Go
- 星标
- 141
- 派生
- 28
- 平均合并
- 1 天 15 小时
- 30 天内合并 PR
- 113
环境准备
- 提供 Dockerfile 或 Docker Compose 文件
- 有 Pull Request 模板
- 阅读贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
Tencent/LoopForge 的其他 Issue
-
难度 2/5 1-3 小时 新手友好度 74/100
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 75/100
维护者通常 1 天内回复
-
[Bug]: 官方镜像未安装 wecom-cli,企业微信通知报「通知服务未安装 wecom-cli」可能已有人在做 @newexploreor 于 1 天前认领。 未关闭bug
难度 2/5 1-3 小时 新手友好度 76/100
Tencent/LoopForge#156 · 1 条评论 · 已指派 1 人 ·
维护者通常 1 天内回复
-
【架构优化】合并 gitwork/workbranch.go 中 push/pull 重复的默认提交身份注入为 withFallbackIdentity可能已有人在做 @fx-kurumi 今天认领。 未关闭
难度 2/5 1-3 小时 新手友好度 40/100
维护者通常 1 天内回复
-
【架构优化】从 runtime.installNPMCLI 中拆出 npm 参数拼装 npmCLIInstallArgs 与安装结果启用 activateNPMStage可能已有人在做 @fx-kurumi 今天认领。 未关闭
难度 2/5 1-3 小时 新手友好度 30/100
维护者通常 1 天内回复
查看 Tencent/LoopForge 的全部 Issue
相似的 Issue
-
team:library-maintainers
难度 2/5 1-3 小时 新手友好度 82/100
padok-team/burrito#1208 · 1 条评论 ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 62/100
bazel-contrib/rules_go#4784 · 1 条评论 ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 75/100
-
难度 2/5 1-3 小时 新手友好度 62/100
POSIdev-community/aictl#40 ·
-
难度 1/5 1 小时以内 新手友好度 62/100
prime-radiant-inc/evener#6306 ·
维护者通常 1 天内回复