code-collision is annotated on the enum declaration, not on the colliding variant
维护者通常 1 天内回复
还没有人认领这个 Issue。
评估
- 难度
- 4/5
- 预计耗时
- 3-5 天
- 新手友好度
- 35/100
- Issue 类型
- 缺陷
- 描述清晰度
- 描述清楚
- 活跃度
- 冷清
- 技术栈
- github-actions, javascript
调研方向
Read VENDORING.md and the code-collision branch in src/analyze.js, then locate the corresponding code and tests in the upstream codepact-core repository. Trace how spans stores enum values and find the collision test; done means shared codes each produce an annotation on the colliding variant’s line, the example annotates line 8, and the self-test passes. The issue requires an upstream change followed by a separate port here.
由索引模型根据 Issue 内容生成。
描述
What happens
When two contracts define the same error code, the annotation lands on the line of the #[contracterror] attribute rather than on the variant that actually collides.
Given examples/broken/factory_error.rs, the annotation appears on line 4 (the attribute) even though the collision is NotInitialized = 300 on line 8.
Why it matters
The entire point of the action is that a reviewer sees the problem on the diff. If someone adds a single colliding variant, GitHub shows the annotation several lines above their change, and if the enum declaration is outside the diff hunk, the annotation is collapsed out of view entirely. The finding is correct and invisible, which is close to useless.
Where
src/analyze.js, the code-collision branch. It reports line: b.declaration.line, because the collision is computed from a set intersection after per-enum information has been flattened away:
const shared = Array.from(a.values).filter((value) => b.values.has(value))
The spans structure keeps values as a Set of numbers, so the variant that owns each value is lost by the time the finding is created.
Suggested fix
Keep a Map from value to variant when building spans, then emit one finding per shared code, located on that variant's line. That also improves the message, which can name the specific variant on each side rather than just the two enums.
A collision involving several shared codes should produce several annotations, one per code, rather than one annotation listing them all.
Note on where to fix it
src/analyze.js is vendored from codepact-core — see VENDORING.md. Fix it in codepact-core first, then port the change here in a second pull request that names the upstream commit.
Acceptance
- A test in
codepact-coreasserting the reported line is the variant's line. - Running the action against
examples/brokenannotates line 8 offactory_error.rs. - The existing self-test job still passes.
- 主要语言
- JavaScript
- 星标
- 0
- 派生
- 0
- 平均合并
- 7 小时 28 分钟
- 30 天内合并 PR
- 10
环境准备
- 没有 Dockerfile 或 Docker Compose 文件
- 没有 Pull Request 模板
- 阅读贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
codepacct/codepact-action 的其他 Issue
-
documentation good first issue wave
难度 2/5 1-3 小时 新手友好度 78/100
codepacct/codepact-action#68 ·
维护者通常 1 天内回复
-
documentation good first issue wave
难度 2/5 1-3 小时 新手友好度 86/100
codepacct/codepact-action#67 ·
维护者通常 1 天内回复
-
good first issue tests wave
难度 2/5 1-3 小时 新手友好度 76/100
codepacct/codepact-action#66 ·
维护者通常 1 天内回复
-
good first issue tests wave
难度 1/5 1-3 小时 新手友好度 79/100
codepacct/codepact-action#65 ·
维护者通常 1 天内回复
-
good first issue tests wave
难度 2/5 1-3 小时 新手友好度 84/100
codepacct/codepact-action#64 ·
维护者通常 1 天内回复
查看 codepacct/codepact-action 的全部 Issue
相似的 Issue
-
bug security
难度 2/5 1-3 小时 新手友好度 76/100
IbrahimHafez1/loadwise#251 ·
维护者通常 1 天内回复
-
documentation good first issue
难度 2/5 1-3 小时 新手友好度 87/100
erkamyaman/unslop-anything#421 ·
维护者通常 1 天内回复