Skip to content

Commit

Permalink
fix: switch do statement to a for statement and start random number c…
Browse files Browse the repository at this point in the history
…ount at 1
  • Loading branch information
mcarvin8 committed Mar 6, 2024
1 parent 8bc11e5 commit 1c29323
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions src/helpers/convertToGenericCoverageReport.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<lineToCover lineNumber="${randomLineNumber}" covered="true"/>\n`;
for (let randomLineNumber = 1; randomLineNumber <= totalLines; randomLineNumber++) {
if (
!uncoveredLines.includes(randomLineNumber) &&
!coveredLines.includes(randomLineNumber) &&
!randomLines.includes(randomLineNumber)
) {
xml += `\t\t<lineToCover lineNumber="${randomLineNumber}" covered="true"/>\n`;
randomLines.push(randomLineNumber);
}
}
} else {
xml += `\t\t<lineToCover lineNumber="${coveredLine}" covered="true"/>\n`;
}
Expand Down

0 comments on commit 1c29323

Please sign in to comment.