Skip to content

[code-simplifier] refactor: remove duplicate instructionsPath declarations and inline normalized variable #81

@github-actions

Description

@github-actions

Code Simplification - 2026-03-23

This PR simplifies recently modified code from PR #79 to improve clarity and reduce duplication while preserving all functionality.

Files Simplified

  • vscode-extension/src/commands/init.ts — Extracted repeated instructionsPath path computation to a single const declaration
  • packages/core/src/services/evalScaffold.ts — Inlined single-use normalized intermediate variable

Improvements Made

  1. Eliminated Duplication (DRY)

    • vscode-extension/src/commands/init.ts: The path path.join(workspacePath, ".github", "copilot-instructions.md") was computed 4 times across the function body (3 times as instructionsPath and once as instrPath — a different name for the same value). Hoisting it to a single declaration at the top of the withProgress callback removes this repetition and makes the code easier to maintain.
  2. Removed Unnecessary Intermediate Variable

    • packages/core/src/services/evalScaffold.ts: The normalized variable was assigned and immediately returned on the next line. Inlining it into the return statement makes the intent clearer.

Changes Based On

Recent changes from:

Testing

  • ✅ No functional changes — behavior is identical
  • ⚠️ node_modules was not available in the execution environment, so npm test, npm run typecheck, npm run lint, and npm run build could not be executed. The changes are purely mechanical refactorings (hoisting a const declaration and removing a single-use intermediate variable) with no semantic impact.

Generated by Code Simplifier ·

  • expires on Mar 24, 2026, 12:46 PM UTC

Note

This was originally intended as a pull request, but GitHub Actions is not permitted to create or approve pull requests in this repository.
The changes have been pushed to branch code-simplifier/2026-03-23-93d60e765e7fbcc8.

Click here to create the pull request

To fix the permissions issue, go to SettingsActionsGeneral and enable Allow GitHub Actions to create and approve pull requests.

Show patch preview (86 of 86 lines)
From da65509c3d2e4ebd07a8bf737e464e6cdf3302d5 Mon Sep 17 00:00:00 2001
From: Copilot <223556219+Copilot@users.noreply.github.com>
Date: Mon, 23 Mar 2026 12:44:27 +0000
Subject: [PATCH] refactor: remove duplicate instructionsPath declarations and
 inline normalized variable

- vscode-extension/src/commands/init.ts: Extract the repeated
  instructionsPath computation (defined 4 times, once as instrPath)
  to a single const at the top of the withProgress callback.
- packages/core/src/services/evalScaffold.ts: Inline the single-use
  normalized intermediate variable into the return statement.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
---
 packages/core/src/services/evalScaffold.ts |  3 +--
 vscode-extension/src/commands/init.ts      | 11 ++---------
 2 files changed, 3 insertions(+), 11 deletions(-)

diff --git a/packages/core/src/services/evalScaffold.ts b/packages/core/src/services/evalScaffold.ts
index ee5af56..81aa681 100644
--- a/packages/core/src/services/evalScaffold.ts
+++ b/packages/core/src/services/evalScaffold.ts
@@ -185,8 +185,7 @@ export async function generateEvalScaffold(options: EvalScaffoldOptions): Promis
     }
 
     const hasAreas = Boolean(options.areas?.length);
-    const normalized = normalizeEvalConfig(parsed, count, hasAreas);
-    return normalized;
+    return normalizeEvalConfig(parsed, count, hasAreas);
   } finally {
     await client.stop();
   }
diff --git a/vscode-extension/src/commands/init.ts b/vscode-extension/src/commands/init.ts
index 242d007..24cbba5 100644
--- a/vscode-extension/src/commands/init.ts
+++ b/vscode-extension/src/commands/init.ts
@@ -26,6 +26,7 @@ export async function initCommand(): Promise<void> {
     async (progress) => {
       try {
         const reporter = new VscodeProgressReporter(progress);
+        const instructionsPath = path.join(workspacePath, ".github", "copilot-instructions.md");
 
         reporter.update("Analyzing repository…");
         const analysis = await analyz
... (truncated)

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions