Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
public format(fileName: string, summary: FileSummary): undefined {
this.fixed += summary.fixes;
if (summary.failures.length === 0)
return;
const mapped: FailureInfo[] = [];
for (const failure of summary.failures.slice().sort(Failure.compare)) {
if (failure.fix !== undefined)
++this.fixable;
if (failure.severity.length > this.maxSeverityWidth)
this.maxSeverityWidth = failure.severity.length;
if (failure.ruleName.length > this.maxNameWidth)
this.maxNameWidth = failure.ruleName.length;
let {character, line} = failure.start;
if (line !== 0 || character === 0 || !summary.content.startsWith('\uFEFF'))
character += 1; // avoid incrementing the character position on the first line if BOM is present, editors ignore BOM
const position = `${line + 1}:${character}`;
if (position.length > this.maxPositionWidth)
this.maxPositionWidth = position.length;
mapped.push({
position,
severity: failure.severity,
ruleName: failure.ruleName,