magic-number: numbers that are already named are reported (regex contents, `?? N` config fallbacks, parameter defaults, product factors, radix)
维护者通常 1 天内回复
还没有人认领这个 Issue。
评估
- 难度
- 4/5
- 预计耗时
- 3-5 天
- 新手友好度
- 45/100
- Issue 类型
- 缺陷
- 描述清晰度
- 基本清楚
- 活跃度
- 活跃
- 技术栈
- typescript
- 领域
- tooling
调研方向
Start with magic-number-prevention.ts, especially lines 168–177 and 224–227, and trace how the detector masks source text and exempts named values. Review its tests for regex literals, nullish coalescing, defaults, products, collections, radix arguments, and template substitutions; the issue gives example source patterns but does not name test files. Done when those false findings are excluded and template substitutions are scanned, while the listed real magic-number findings remain detectable.
由索引模型根据 Issue 内容生成。
描述
Found in the 8.0.0 self-audit triage: RoC 7.29.1 (npm, 5fc54afe) on a clean clone of develop at 2d2fa9a, with typescript resolvable (verdict compliance, 0 failed / 46 warnings). The bucket method and per-law tables are kept by QA; counts are from that run.
What happens
Magic Number Prevention reported 302 literals in 106 files; 40 files contain only these kinds of false findings (re-run of the detector's own loop, 0 mismatches):
- inside regex literals (75 literals): skipped but not blanked (magic-number-prevention.ts:224-227), so
{0,300}is a "magic number"; config.thresholds?.x ?? 50(55): the config key names the number; the exemption only acceptsconst X =orkey:on the same line (:168-177), and misses??at the end of the previous line;- later factors of a named product (
MAX_AGE = 24 * 60 * 60 * 1000, 10), parameter/destructuring defaults (before = 50, 8), elements of a namedSet,parseInt(x, 16).
Also a false negative:${…}inside template literals is blanked, soslice(0, 57)there is never seen.
Real debt remains (66 files): score deductions (score -= 25), unnamed length limits (the same .slice(0, 80) in 5 files), ratio cutoffs, version checks.
Suggested direction
Blank regex contents; treat as named: <chain> ?? N, ident = N in parameters/destructuring, every factor of a product whose first factor is exempt, elements of a named array/Set, the radix argument; scan template substitutions.
- 主要语言
- TypeScript
- 星标
- 0
- 派生
- 0
- 平均合并
- 38 分钟
- 30 天内合并 PR
- 96
环境准备
- 没有 Dockerfile 或 Docker Compose 文件
- 有 Pull Request 模板
- 阅读贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
Rule-Of-Code/RoC 的其他 Issue
-
bug
难度 2/5 1-3 小时 新手友好度 78/100
Rule-Of-Code/RoC#436 ·
维护者通常 1 天内回复
-
bug
难度 5/5 一周以上 新手友好度 35/100
Rule-Of-Code/RoC#439 · 1 条评论 ·
维护者通常 1 天内回复
-
bug
难度 4/5 3-5 天 新手友好度 49/100
Rule-Of-Code/RoC#438 ·
维护者通常 1 天内回复
-
bug
难度 3/5 1-2 天 新手友好度 53/100
Rule-Of-Code/RoC#437 ·
维护者通常 1 天内回复
-
bug
难度 3/5 1-2 天 新手友好度 74/100
Rule-Of-Code/RoC#435 ·
维护者通常 1 天内回复
相似的 Issue
-
ready-for-agent
难度 1/5 1 小时以内 新手友好度 86/100
LucasSantana-Dev/Lucky#3257 ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 75/100
XiaomiMiMo/MiMo-Code#2849 · 1 条评论 ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 67/100
danielmiessler/LifeOS#2894 ·
维护者通常 5 天内回复
-
enhancement frontend good first issue help wanted testing-infrastructure
难度 2/5 1-3 小时 新手友好度 76/100
维护者通常 2 天内回复
-
enhancement follow-up
难度 2/5 1-3 小时 新手友好度 76/100
维护者通常 1 天内回复