CRAP |
Complexity |
Coverage |
Location |
1.00 |
1 |
9/9 (100.00%) |
crap/lint.service.ts
(L45 - L86)
|
private match({
coverageFunction,
lintReport,
type,
}: {
coverageFunction: FunctionMapping;
lintReport: Array<FunctionComplexity | null>;
type: "function" | "enum" | "class" | "export";
}) {
const overlappingLintFunctions = lintReport.filter((lintFunction): lintFunction is FunctionComplexity => {
if (!lintFunction || lintFunction.type !== type) {
return false;
}
/*
* The istanbul function is reported sometimes to start just before the range reported by ESLint,
* so we also check for the end of the range.
*/
return (
locationIsInRange({ location: coverageFunction.loc.start, range: lintFunction }) ||
locationIsInRange({ location: coverageFunction.loc.end, range: lintFunction })
);
});
/*
* Filter out lint functions that contain other matching functions,
* so when matching functions inside functions we find the inner-most function that matches the position of the
* coverage function.
*/
return overlappingLintFunctions.filter((lintFunction) => {
return !overlappingLintFunctions.some((containedLintFunction) => {
if (containedLintFunction === lintFunction) {
return false;
}
return locationIsInRange({
location: containedLintFunction.start,
range: lintFunction,
});
});
});
}