[Duplicate Code] NVX artifact manifest fixture duplicated across artifact-manifest and preflight tests

Aperta Adatta ai principianti
#12,345 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à
2/5
Tempo stimato
1-3 ore
Idoneità per principianti
78/100
Tipo di issue
Refactoring
Chiarezza
Specificata chiaramente
Stato di attività
Attiva
Stack tecnologico
typescript
Ambito
testing

Direzione di ricerca

Leggi src/nvx/artifact-manifest.test.ts e src/nvx/preflight.test.ts nelle posizioni dei fixture elencate, poi esamina come ciascun test usa i propri valori di manifest e digest. Estrai un fixture condiviso per la creazione dell’oggetto che supporti le diverse esigenze relative al digest, facendo sì che preflight lo serializzi come JSON. Il lavoro è completato quando entrambi i test usano il fixture condiviso e continuano a ricevere i dati del manifest necessari.

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

Descrizione

code-quality refactoring

Duplicate Code Opportunity

Summary
  • Pattern: The NVX artifact-manifest fixture (schemaVersion 2 release/upstream/artifacts object, including the signer-workflow and release-tag constants) is hand-built in two test files.
  • Locations: src/nvx/artifact-manifest.test.ts lines 18-33; src/nvx/preflight.test.ts lines 27-42
  • Impact: About 16 duplicated lines (jscpd). A manifest schema bump or signer-identity change must be applied to both fixtures, or they drift silently.
Evidence

src/nvx/artifact-manifest.test.ts lines 18-33:

function manifest() {
  return {
    schemaVersion: 2,
    release: {
      repository: NVX_ARTIFACT_REPOSITORY,
      workflow: NVX_ARTIFACT_SIGNER_WORKFLOW,
      tag: NVX_ARTIFACT_RELEASE_TAG,
      sourceCommit: 'a'.repeat(40),
    },
    upstream: {
      releaseTag: NVX_RELEASE_TAG,
      nvxCommit: NVX_COMMIT,
      openvmmCommit: NVX_OPENVMM_COMMIT,
    },
    architecture: 'x86_64',
    artifacts: {
      openvmm: { file: 'openvmm', sizeBytes: 100, sha256: '2'.repeat(64) },

src/nvx/preflight.test.ts lines 27-42:

function manifest() {
  return JSON.stringify({
    schemaVersion: 2,
    release: {
      repository: NVX_ARTIFACT_REPOSITORY,
      workflow: NVX_ARTIFACT_SIGNER_WORKFLOW,
      tag: NVX_ARTIFACT_RELEASE_TAG,
      sourceCommit: 'a'.repeat(40),
    },
    upstream: {
      releaseTag: NVX_RELEASE_TAG,
      nvxCommit: NVX_COMMIT,
      openvmmCommit: NVX_OPENVMM_COMMIT,
    },
    architecture: 'x86_64',
    artifacts: {
      openvmm: { file: 'openvmm', sizeBytes: 100, sha256: DIGESTS.openvmm },

The two fixtures differ only in return form (object vs. JSON.stringify) and in the openvmm digest source.

Suggested Refactoring
  • Extract a shared buildNvxArtifactManifest(overrides?) test helper (for example src/nvx/test-fixtures.ts) that returns the object form. preflight.test.ts wraps it with JSON.stringify and passes its digest override.
  • Keep the signer-workflow and release-tag constants in one place so the fixtures cannot diverge.
Affected Files
  • src/nvx/artifact-manifest.test.ts — lines 18-33
  • src/nvx/preflight.test.ts — lines 27-42
Effort Estimate

Low

Score: 4 (borderline). Signer-identity relevance is the only factor that clears the threshold. No production-code duplication reached it in this run.


Detected by Duplicate Code Detector workflow. Run date: 2026-11-29

Generated by Duplicate Code Detector · copilot · routed: haiku55 xhigh · ~3 AIC · ⊞ 18.3K · history

  • expires on Dec 29, 2026, 9:57 PM UTC
Lingua principale
TypeScript
Stelle
169
Fork
89
Merge medio
5h 18m
PR unite (30g)
450

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 github/gh-aw-firewall

Tutte le issue di github/gh-aw-firewall

Issue simili

Altre issue su TypeScript

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.