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

オープン 初心者向け
#12,345 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

メンテナーはふだん 1 日以内に返信

まだ誰も着手していません。

評価

難易度
2/5
見積もり時間
1〜3時間
初心者へのやさしさ
78/100
issue の種類
リファクタリング
明瞭さ
明確に書かれている
活発さ
活発
技術スタック
typescript
領域
testing

調査の方向性

記載されているfixtureの場所で src/nvx/artifact-manifest.test.ts と src/nvx/preflight.test.ts を読み、各テストがmanifestとdigestの値をどのように使っているかを調べます。異なるdigestの要件に対応する、オブジェクト構築用の共通fixtureを抽出し、preflightではそれをJSONとしてシリアライズします。両方のテストが共通fixtureを使い、必要なmanifestデータを引き続き受け取る状態になれば完了です。

索引モデルが issue の本文から書いたものです。

説明

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
主要言語
TypeScript
スター
169
フォーク
89
平均マージ
5時間 18分
マージ済み PR(30日)
450

環境構築

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

github/gh-aw-firewall のほかの issue

github/gh-aw-firewall の issue をすべて見る

似ている issue

TypeScript の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。