Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 | 2x 7x 5x 5x 5x 2x 2x 2x | import { XMLParser } from 'fast-xml-parser';
import type { BaseParser, Results } from './base';
import * as is from '../guards';
import { extname } from 'path';
import type { CloverReport } from '../guards/xml';
export class CloverParser implements BaseParser<CloverReport> {
globs = ['**/*/clover.xml', 'clover.xml'];
matches(name: string, contents: string) {
if (extname(name) !== '.xml') return false;
const parser = new XMLParser({
ignoreAttributes: false,
parseAttributeValue: true,
});
const result = parser.parse(contents);
return is.xml.clover(result) ? result : false;
}
public parse(report: CloverReport): Results {
const { metrics } = report.coverage.project;
return {
branches: metrics['@_coveredconditionals'] / metrics['@_conditionals'],
functions: metrics['@_coveredmethods'] / metrics['@_methods'],
lines: metrics['@_coveredstatements'] / metrics['@_statements'],
};
}
}
export const clover = new CloverParser();
|