Skip to content

Commit da27e47

Browse files
committed
fix(rules): align isCodePath with isCodeFile module/JVM extensions
isCodePath lagged SOURCE_FILE_EXTENSION/isCodeFile for .mts/.cts/.mjs/.cjs/.kts/.scala/.groovy, so annotatablePullRequestFiles dropped those paths before Missing test evidence annotations could land. Add the seven extensions and a parity regression covering each. Closes #9322
1 parent 83b6867 commit da27e47

2 files changed

Lines changed: 33 additions & 1 deletion

File tree

src/rules/advisory.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -551,7 +551,8 @@ 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+
// Keep parity with isCodeFile / SOURCE_FILE_EXTENSION (#9322): include .mts/.cts/.mjs/.cjs/.kts/.scala/.groovy.
555+
return /\.(ts|tsx|mts|cts|js|jsx|mjs|cjs|py|go|rs|java|rb|php|cs|cpp|cc|c|h|hpp|swift|kt|kts|scala|groovy|m|sql|yaml|yml|json|toml|md|vue|svelte|astro|dart)$/i.test(path);
555556
}
556557

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

test/unit/rules.test.ts

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1638,6 +1638,37 @@ describe("advisory rules", () => {
16381638
}
16391639
});
16401640

1641+
it("flags Missing test evidence for .mts/.cts/.mjs/.cjs/.kts/.scala/.groovy via isCodePath + isCodeFile parity (#9322)", () => {
1642+
// Regression: isCodeFile recognizes these via SOURCE_FILE_EXTENSION, but isCodePath lagged — so
1643+
// annotatablePullRequestFiles dropped them before Missing test evidence annotations could land.
1644+
const advisory = buildPullRequestAdvisory(repo, {
1645+
repoFullName: repo.fullName, number: 26, title: "Add module/JVM sources without tests", state: "open",
1646+
authorLogin: "contributor", authorAssociation: "NONE", labels: [], linkedIssues: [],
1647+
});
1648+
const sourcePaths = [
1649+
"src/loader.mts",
1650+
"src/setup.cts",
1651+
"src/legacy.mjs",
1652+
"src/compat.cjs",
1653+
"build.kts",
1654+
"src/Main.scala",
1655+
"src/App.groovy",
1656+
];
1657+
const files: PullRequestFileRecord[] = sourcePaths.map((path) => ({
1658+
repoFullName: repo.fullName, pullNumber: 26, path, additions: 10, deletions: 0, changes: 10, payload: {},
1659+
}));
1660+
const collisions: CollisionReport = {
1661+
repoFullName: repo.fullName, generatedAt: "2026-06-10T00:00:00.000Z",
1662+
summary: { clusterCount: 0, highRiskCount: 0, itemsReviewed: 0 }, clusters: [],
1663+
};
1664+
1665+
const { annotations } = buildCheckRunAnnotations(advisory, { files, collisions, pullNumber: 26 }, "standard");
1666+
1667+
for (const path of sourcePaths) {
1668+
expect(annotations.some((entry) => entry.title === "Missing test evidence" && entry.path === path)).toBe(true);
1669+
}
1670+
});
1671+
16411672
it("buildCheckRunAnnotations uses notice level for medium-risk collisions and critical public finding text", () => {
16421673
const advisory = {
16431674
...buildPullRequestAdvisory(repo, null),

0 commit comments

Comments
 (0)