core/parsers/tool.phpmd.parser.ts
core/parsers/tool.phpmd.parser.ts is a file in GovLab Quality. 21 lines of code and 2 definitions.
import { numberField, recordsAt, stringField } from "#core/selectors/record.selector";
import type { Finding } from "#types/finding.types";
import { POSITION } from "#configuration/constants/tool.constants";
import { jsonRecordsAt } from "#core/parsers/record.parser";
import { toolFinding } from "#core/factories/finding.factory";
const TOOL = "phpmd";
export const parsePhpmdOutput = function parsePhpmdOutput(stdout: string, ecosystem: string): Finding[] {
return jsonRecordsAt(stdout || "{}", "files").flatMap((file) =>
recordsAt(file, "violations").map((violation) =>
toolFinding({
column: POSITION,
ecosystem,
file: stringField(file, "file"),
line: numberField(violation, "beginLine", POSITION),
message: stringField(violation, "description"),
ruleId: stringField(violation, "rule", TOOL),
tool: TOOL,
}),
),
);
};