From a36639034bb9e2766bc0df526a7eb275d112c436 Mon Sep 17 00:00:00 2001 From: gnanam1990 Date: Thu, 9 Apr 2026 17:34:22 +0530 Subject: [PATCH] fix: remove unused imports and variables flagged by CodeQL Co-Authored-By: Claude Opus 4.6 (1M context) --- src/context.repoMap.test.ts | 2 +- src/context/repoMap/gitFiles.ts | 2 +- src/context/repoMap/pagerank.ts | 2 -- src/context/repoMap/repoMap.test.ts | 3 +-- src/tools/RepoMapTool/RepoMapTool.test.ts | 23 ++--------------------- 5 files changed, 5 insertions(+), 27 deletions(-) diff --git a/src/context.repoMap.test.ts b/src/context.repoMap.test.ts index 31215e1f..769d4fb1 100644 --- a/src/context.repoMap.test.ts +++ b/src/context.repoMap.test.ts @@ -1,4 +1,4 @@ -import { describe, expect, test, mock, beforeEach } from 'bun:test' +import { describe, expect, test } from 'bun:test' // The feature() function from bun:bundle is shimmed at build time. // In tests, it's not available, so we test the getRepoMapContext logic diff --git a/src/context/repoMap/gitFiles.ts b/src/context/repoMap/gitFiles.ts index a8961d6f..ede9ff77 100644 --- a/src/context/repoMap/gitFiles.ts +++ b/src/context/repoMap/gitFiles.ts @@ -1,5 +1,5 @@ import { execFile } from 'child_process' -import { readdirSync, statSync } from 'fs' +import { readdirSync } from 'fs' import { join, relative } from 'path' import type { SupportedLanguage } from './types.js' diff --git a/src/context/repoMap/pagerank.ts b/src/context/repoMap/pagerank.ts index cd00ebc8..9fd48289 100644 --- a/src/context/repoMap/pagerank.ts +++ b/src/context/repoMap/pagerank.ts @@ -20,8 +20,6 @@ export function rankFiles( ): RankedFile[] { if (graph.order === 0) return [] - // Build personalization vector - const focusSet = new Set(focusFiles) const hasPersonalization = focusFiles.length > 0 // graphology-pagerank accepts getEdgeWeight option diff --git a/src/context/repoMap/repoMap.test.ts b/src/context/repoMap/repoMap.test.ts index 75d4b4d3..1d8af0ae 100644 --- a/src/context/repoMap/repoMap.test.ts +++ b/src/context/repoMap/repoMap.test.ts @@ -1,5 +1,5 @@ import { afterEach, beforeAll, describe, expect, test } from 'bun:test' -import { cpSync, existsSync, mkdirSync, mkdtempSync, rmSync, utimesSync, writeFileSync } from 'fs' +import { cpSync, mkdtempSync, rmSync, utimesSync, writeFileSync } from 'fs' import { tmpdir } from 'os' import { join } from 'path' import { invalidateCache, buildRepoMap } from './index.js' @@ -134,7 +134,6 @@ describe('renderer', () => { // Every file header in the output should have its signatures listed for (const header of fileHeaders) { - const fileName = header.slice(0, -1) // remove trailing ':' // The file must have at least one signature line after it const headerIdx = result.map.indexOf(header) const afterHeader = result.map.slice(headerIdx + header.length) diff --git a/src/tools/RepoMapTool/RepoMapTool.test.ts b/src/tools/RepoMapTool/RepoMapTool.test.ts index 6b7b8b87..1658f36b 100644 --- a/src/tools/RepoMapTool/RepoMapTool.test.ts +++ b/src/tools/RepoMapTool/RepoMapTool.test.ts @@ -1,8 +1,7 @@ -import { afterEach, beforeAll, describe, expect, test } from 'bun:test' -import { cpSync, mkdtempSync, rmSync, writeFileSync } from 'fs' +import { beforeAll, describe, expect, test } from 'bun:test' +import { cpSync, mkdtempSync, rmSync } from 'fs' import { tmpdir } from 'os' import { join } from 'path' -import { z } from 'zod/v4' import { initParser } from '../../context/repoMap/parser.js' import { invalidateCache } from '../../context/repoMap/index.js' import { RepoMapTool } from './RepoMapTool.js' @@ -29,24 +28,6 @@ beforeAll(async () => { await initParser() }) -// Minimal context stub for tool.call -function makeContext(root: string) { - // Patch getCwd to return our test root - process.env.__TEST_CWD_OVERRIDE = root - return { - abortController: new AbortController(), - getAppState: () => ({ - toolPermissionContext: { - mode: 'default' as const, - additionalWorkingDirectories: new Map(), - alwaysAllowRules: {}, - alwaysDenyRules: {}, - alwaysAskRules: {}, - isBypassPermissionsModeAvailable: false, - }, - }), - } as any -} describe('RepoMapTool schema', () => { test('validates a minimal input {}', () => {