@redocly/cli
Version:
[@Redocly](https://redocly.com) CLI is your all-in-one API documentation utility. It builds, manages, improves, and quality-checks your API descriptions, all of which comes in handy for various phases of the API Lifecycle. Create your own rulesets to make
28 lines • 1.33 kB
JavaScript
import { getLineColLocation, logger, xmlEscape } from '@redocly/openapi-core';
import { bold, cyan, white } from 'colorette';
export function printScorecardResultsAsCheckstyle(path, problems, achievedLevel, targetLevelAchieved) {
if (targetLevelAchieved) {
logger.info(white(bold(`\n ☑️ Achieved Level: ${cyan(achievedLevel)}\n\n`)));
}
logger.output('<?xml version="1.0" encoding="UTF-8"?>\n');
logger.output(`<checkstyle version="4.3">\n`);
logger.output(`<file name="${xmlEscape(path)}">\n`);
for (const problem of problems) {
const loc = problem.location[0];
let line = 0;
let col = 0;
if (loc) {
const lineColLoc = getLineColLocation(loc);
line = lineColLoc.start.line;
col = lineColLoc.start.col;
}
const level = problem.scorecardLevel || 'Unknown';
const severity = problem.severity === 'warn' ? 'warning' : 'error';
const message = xmlEscape(problem.message);
const source = xmlEscape(`${level}:${problem.ruleId}`);
logger.output(`<error line="${line}" column="${col}" severity="${severity}" message="${message}" source="${source}" />\n`);
}
logger.output(`</file>\n`);
logger.output(`</checkstyle>\n\n`);
}
//# sourceMappingURL=checkstyle-formatter.js.map