code-duplication: a "block" is the tail after the last arrow line, and message tables normalise to the same text

未关闭
#432 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

维护者通常 1 天内回复

还没有人认领这个 Issue。

评估

难度
4/5
预计耗时
3-5 天
新手友好度
46/100
Issue 类型
缺陷
描述清晰度
基本清楚
活跃度
活跃
技术栈
typescript
领域
tooling

调研方向

Start with code-duplication-control.ts around lines 95, 153–157, and 194, then read the law’s satisfiedBy description and its tests to understand the intended definition of duplication. Compare the current findings with the self-audit counts in the issue, including the copied helpers that should remain flagged. Done means one-line idioms, type members, and message tables with different text stop being reported while genuine copied function bodies are still detected.

由索引模型根据 Issue 内容生成。

描述

bug

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

Code Duplication Control (37 findings) extracts "blocks" by restarting at every line containing => or function (code-duplication-control.ts:153-157) and replaces every string literal with STR (:194), with a 50-character minimum (:95). Result: one-line idioms, call-site fragments, type members (checker: (c) => boolean) and message tables with different text are "duplicates" (16 ii-a + 2 from the detector's own example tables). 12 findings are real copied helpers (several safeReadFile/escapeRe/stripComments/mergeResults copies) and should stay.

Suggested direction

Compare real function/method bodies from the TypeScript AST with a token/line floor (the law's own satisfiedBy talks about identical function bodies), or consume jscpd output — the repository already has jscpd as a devDependency.

主要语言
TypeScript
星标
0
派生
0
平均合并
38 分钟
30 天内合并 PR
96

环境准备

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

Rule-Of-Code/RoC 的其他 Issue

查看 Rule-Of-Code/RoC 的全部 Issue

相似的 Issue

更多 TypeScript Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。