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

Aperta
#2 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
4/5
Tempo stimato
3-5 giorni
Idoneità per principianti
35/100
Tipo di issue
Bug
Chiarezza
Specificata chiaramente
Stato di attività
Tranquilla
Stack tecnologico
github-actions, javascript
Ambito
devtools, testing

Direzione di ricerca

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.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

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.
Lingua principale
JavaScript
Stelle
0
Fork
0
Merge medio
7h 28m
PR unite (30g)
10

Preparare l'ambiente

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di codepacct/codepact-action

Tutte le issue di codepacct/codepact-action

Issue simili

Altre issue su JavaScript

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.