diff --git a/src/helpers/convertToGenericCoverageReport.ts b/src/helpers/convertToGenericCoverageReport.ts index ab2604e..6559bee 100644 --- a/src/helpers/convertToGenericCoverageReport.ts +++ b/src/helpers/convertToGenericCoverageReport.ts @@ -33,12 +33,16 @@ export function convertToGenericCoverageReport(data: CoverageData, dxDirectory: for (const coveredLine of coveredLines) { if (coveredLine > totalLines) { - let randomLineNumber; - do { - randomLineNumber = Math.floor(Math.random() * totalLines) + 1; - } while (coveredLines.includes(randomLineNumber) || uncoveredLines.includes(randomLineNumber) || randomLines.includes(randomLineNumber)); - randomLines.push(randomLineNumber); - xml += `\t\t\n`; + for (let randomLineNumber = 1; randomLineNumber <= totalLines; randomLineNumber++) { + if ( + !uncoveredLines.includes(randomLineNumber) && + !coveredLines.includes(randomLineNumber) && + !randomLines.includes(randomLineNumber) + ) { + xml += `\t\t\n`; + randomLines.push(randomLineNumber); + } + } } else { xml += `\t\t\n`; }