Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions src/sarif.ts
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,14 @@ export const RULES: readonly SarifRule[] = [
helpUri: HELP_BASE,
defaultLevel: "warning",
},
{
id: "duplicate-name",
name: "duplicateName",
shortDescription:
"Two or more skills share the same name value; resolution is ambiguous.",
helpUri: HELP_BASE,
defaultLevel: "warning",
},
];

const SEVERITY_TO_LEVEL: Record<Severity, SarifLevel> = {
Expand Down
28 changes: 28 additions & 0 deletions test/sarif.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,37 @@ describe("reportSarif", () => {
expect(ruleIds).toContain("tool-unknown");
expect(ruleIds).toContain("description-collision");
expect(ruleIds).toContain("tools-overloaded");
expect(ruleIds).toContain("duplicate-name");
expect(out.runs[0].results).toEqual([]);
});

it("includes duplicate-name in the catalog with a proper description", () => {
const out = JSON.parse(reportSarif([], "/test", opts));
const rule = out.runs[0].tool.driver.rules.find(
(r: { id: string }) => r.id === "duplicate-name",
);
expect(rule).toBeDefined();
expect(rule.name).toBe("duplicateName");
expect(rule.defaultConfiguration.level).toBe("warning");
expect(rule.shortDescription.text).not.toBe("duplicate-name");
});

it("ruleIndex for duplicate-name points to the registered entry, not a fallback", () => {
const diagnostics: Diagnostic[] = [
{
severity: "warn",
rule: "duplicate-name",
message: "skill name 'foo' is also declared in '/b.md'",
file: "/test/a.md",
},
];
const out = JSON.parse(reportSarif(diagnostics, "/test", opts));
const idx = out.runs[0].results[0].ruleIndex;
const rule = out.runs[0].tool.driver.rules[idx];
expect(rule.id).toBe("duplicate-name");
expect(rule.name).toBe("duplicateName");
});

it("emits tools-overloaded at warning level with correct ruleIndex", () => {
const diagnostics: Diagnostic[] = [
{
Expand Down