From 2f245bc980b8688bbb42ea8ce843d351619f3835 Mon Sep 17 00:00:00 2001 From: Jeff <158072326+jeffrey701@users.noreply.github.com> Date: Mon, 27 Jul 2026 16:50:37 +0200 Subject: [PATCH] fix(rules): recognize .mts/.cts/.mjs/.cjs/.kts/.scala/.groovy in isCodePath --- src/rules/advisory.ts | 5 ++++- test/unit/rules.test.ts | 27 +++++++++++++++++++++++++++ 2 files changed, 31 insertions(+), 1 deletion(-) diff --git a/src/rules/advisory.ts b/src/rules/advisory.ts index 2189bb65d2..0e5eda5396 100644 --- a/src/rules/advisory.ts +++ b/src/rules/advisory.ts @@ -551,7 +551,10 @@ function effectiveDisplaySeverity(finding: AdvisoryFinding, blockerCodes: Readon } function isCodePath(path: string): boolean { - return /\.(ts|tsx|js|jsx|py|go|rs|java|rb|php|cs|cpp|cc|c|h|hpp|swift|kt|m|sql|yaml|yml|json|toml|md|vue|svelte|astro|dart)$/i.test(path); + // #9322: keep in parity with SOURCE_FILE_EXTENSION/isCodeFile — the module-variant (.mts/.cts/.mjs/.cjs) and + // JVM (.kts/.scala/.groovy) extensions were missing, so a PR touching only those files was wrongly treated as + // non-code by the annotation gate. Purely additive. + return /\.(ts|tsx|mts|cts|js|jsx|mjs|cjs|py|go|rs|java|kt|kts|scala|groovy|rb|php|cs|cpp|cc|c|h|hpp|swift|m|sql|yaml|yml|json|toml|md|vue|svelte|astro|dart)$/i.test(path); } function collisionClustersForPull(collisions: CollisionReport, pullNumber: number): CollisionCluster[] { diff --git a/test/unit/rules.test.ts b/test/unit/rules.test.ts index 710e72b719..769939fa40 100644 --- a/test/unit/rules.test.ts +++ b/test/unit/rules.test.ts @@ -1617,6 +1617,33 @@ describe("advisory rules", () => { } }); + it("flags Missing test evidence for module-variant/JVM source via isCodePath + isCodeFile parity (#9322)", () => { + // Regression: isCodeFile/SOURCE_FILE_EXTENSION already admitted .mts/.cts/.mjs/.cjs and .kts/.scala/.groovy, + // but advisory.ts isCodePath lagged, so buildCheckRunAnnotations filtered those files out of annotatableFiles + // before missing_tests ran — a PR touching only those extensions was wrongly treated as non-code. + const advisory = buildPullRequestAdvisory(repo, { + repoFullName: repo.fullName, number: 26, title: "Add ESM/JVM source without tests", state: "open", + authorLogin: "contributor", authorAssociation: "NONE", labels: [], linkedIssues: [], + }); + const sourcePaths = [ + "src/loader.mts", "src/loader.cts", "src/loader.mjs", "src/loader.cjs", + "build.kts", "src/main/Widget.scala", "src/main/Task.groovy", + ]; + const files: PullRequestFileRecord[] = sourcePaths.map((path) => ({ + repoFullName: repo.fullName, pullNumber: 26, path, additions: 11, deletions: 0, changes: 11, payload: {}, + })); + const collisions: CollisionReport = { + repoFullName: repo.fullName, generatedAt: "2026-06-10T00:00:00.000Z", + summary: { clusterCount: 0, highRiskCount: 0, itemsReviewed: 0 }, clusters: [], + }; + + const { annotations } = buildCheckRunAnnotations(advisory, { files, collisions, pullNumber: 26 }, "standard"); + + for (const path of sourcePaths) { + expect(annotations.some((entry) => entry.title === "Missing test evidence" && entry.path === path)).toBe(true); + } + }); + it("flags Missing test evidence for Dart source via isCodePath + isCodeFile parity", () => { const advisory = buildPullRequestAdvisory(repo, { repoFullName: repo.fullName, number: 25, title: "Add Dart widget without tests", state: "open",