# test.govlab/quality/core/parsers/tool.shellcheck.parser.test.ts

> 46 lines of code and 0 definitions.

Tree: Codebase Testing
Language: typescript
Canonical: https://banes-lab.com/anatomy/testing#file-testing-test-govlab-quality-core-parsers-tool-shellcheck-parser-test-ts
Source text: https://banes-lab.com/source/testing/test.govlab/quality/core/parsers/tool.shellcheck.parser.test.ts.txt

Listed in [test.govlab/quality/core/parsers](https://banes-lab.com/api/source/testing/test.govlab/quality/core/parsers.md), after [test.govlab/quality/core/parsers/tool.semgrep.parser.test.ts](https://banes-lab.com/source/testing/test.govlab/quality/core/parsers/tool.semgrep.parser.test.ts.md) and before [test.govlab/quality/core/parsers/tool.slither.parser.test.ts](https://banes-lab.com/source/testing/test.govlab/quality/core/parsers/tool.slither.parser.test.ts.md).

## Contained in

- [test.govlab/quality/core/parsers](https://banes-lab.com/anatomy/testing/folder-testing-test-govlab-quality-core-parsers.md)

## Source

```typescript
import { describe, expect, it } from "vitest";
import { parseShellcheckOutput } from "@govlab/quality/core/parsers/tool.shellcheck.parser.ts";

const EXPECTED_COUNT = 2;

const RECORDED = JSON.stringify([
    {
        code: 2086,
        column: 6,
        file: "deploy.sh",
        fix: { replacements: [] },
        level: "info",
        line: 5,
        message: "Double quote to prevent globbing and word splitting.",
    },
    {
        code: 2250,
        column: 1,
        file: "deploy.sh",
        fix: null,
        level: "style",
        line: 4,
        message: "Prefer putting braces around variable references even when not strictly required.",
    },
]);

describe("parseShellcheckOutput", () => {
    it("maps comments to gating (error, advisory:false) Findings with SC<code> ids", () => {
        const findings = parseShellcheckOutput(RECORDED, "shell");
        expect(findings).toHaveLength(EXPECTED_COUNT);
        expect(findings[0]).toMatchObject({
            advisory: false,
            column: 6,
            ecosystem: "shell",
            file: "deploy.sh",
            fixable: true,
            line: 5,
            ruleId: "SC2086",
            severity: "error",
            tool: "shellcheck",
        });
        expect(findings[1]).toMatchObject({ fixable: false, ruleId: "SC2250" });
    });

    it("returns [] on empty, no-comments, or non-JSON output", () => {
        expect(parseShellcheckOutput("", "shell")).toEqual([]);
        expect(parseShellcheckOutput("[]", "shell")).toEqual([]);
        expect(parseShellcheckOutput("not json", "shell")).toEqual([]);
    });
});
```
