Skip to content

Commit 2f245bc

Browse files
committed
fix(rules): recognize .mts/.cts/.mjs/.cjs/.kts/.scala/.groovy in isCodePath
1 parent 86c42c5 commit 2f245bc

2 files changed

Lines changed: 31 additions & 1 deletion

File tree

src/rules/advisory.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -551,7 +551,10 @@ function effectiveDisplaySeverity(finding: AdvisoryFinding, blockerCodes: Readon
551551
}
552552

553553
function isCodePath(path: string): boolean {
554-
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);
554+
// #9322: keep in parity with SOURCE_FILE_EXTENSION/isCodeFile — the module-variant (.mts/.cts/.mjs/.cjs) and
555+
// JVM (.kts/.scala/.groovy) extensions were missing, so a PR touching only those files was wrongly treated as
556+
// non-code by the annotation gate. Purely additive.
557+
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);
555558
}
556559

557560
function collisionClustersForPull(collisions: CollisionReport, pullNumber: number): CollisionCluster[] {

test/unit/rules.test.ts

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1617,6 +1617,33 @@ describe("advisory rules", () => {
16171617
}
16181618
});
16191619

1620+
it("flags Missing test evidence for module-variant/JVM source via isCodePath + isCodeFile parity (#9322)", () => {
1621+
// Regression: isCodeFile/SOURCE_FILE_EXTENSION already admitted .mts/.cts/.mjs/.cjs and .kts/.scala/.groovy,
1622+
// but advisory.ts isCodePath lagged, so buildCheckRunAnnotations filtered those files out of annotatableFiles
1623+
// before missing_tests ran — a PR touching only those extensions was wrongly treated as non-code.
1624+
const advisory = buildPullRequestAdvisory(repo, {
1625+
repoFullName: repo.fullName, number: 26, title: "Add ESM/JVM source without tests", state: "open",
1626+
authorLogin: "contributor", authorAssociation: "NONE", labels: [], linkedIssues: [],
1627+
});
1628+
const sourcePaths = [
1629+
"src/loader.mts", "src/loader.cts", "src/loader.mjs", "src/loader.cjs",
1630+
"build.kts", "src/main/Widget.scala", "src/main/Task.groovy",
1631+
];
1632+
const files: PullRequestFileRecord[] = sourcePaths.map((path) => ({
1633+
repoFullName: repo.fullName, pullNumber: 26, path, additions: 11, deletions: 0, changes: 11, payload: {},
1634+
}));
1635+
const collisions: CollisionReport = {
1636+
repoFullName: repo.fullName, generatedAt: "2026-06-10T00:00:00.000Z",
1637+
summary: { clusterCount: 0, highRiskCount: 0, itemsReviewed: 0 }, clusters: [],
1638+
};
1639+
1640+
const { annotations } = buildCheckRunAnnotations(advisory, { files, collisions, pullNumber: 26 }, "standard");
1641+
1642+
for (const path of sourcePaths) {
1643+
expect(annotations.some((entry) => entry.title === "Missing test evidence" && entry.path === path)).toBe(true);
1644+
}
1645+
});
1646+
16201647
it("flags Missing test evidence for Dart source via isCodePath + isCodeFile parity", () => {
16211648
const advisory = buildPullRequestAdvisory(repo, {
16221649
repoFullName: repo.fullName, number: 25, title: "Add Dart widget without tests", state: "open",

0 commit comments

Comments
 (0)