code-collision is annotated on the enum declaration, not on the colliding variant

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

维护者通常 1 天内回复

还没有人认领这个 Issue。

评估

难度
4/5
预计耗时
3-5 天
新手友好度
35/100
Issue 类型
缺陷
描述清晰度
描述清楚
活跃度
冷清
技术栈
github-actions, javascript
领域
devtools, testing

调研方向

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 内容生成。

描述

bug good first 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-core asserting the reported line is the variant's line.
  • Running the action against examples/broken annotates line 8 of factory_error.rs.
  • The existing self-test job still passes.
主要语言
JavaScript
星标
0
派生
0
平均合并
7 小时 28 分钟
30 天内合并 PR
10

环境准备

  • 没有 Dockerfile 或 Docker Compose 文件
  • 没有 Pull Request 模板
  • 阅读贡献指南

从这里开始

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

codepacct/codepact-action 的其他 Issue

查看 codepacct/codepact-action 的全部 Issue

相似的 Issue

更多 JavaScript Issue

把新 issue 发到你的邮箱

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