Skip to content

Commit 1c29323

Browse files
committed
fix: switch do statement to a for statement and start random number count at 1
1 parent 8bc11e5 commit 1c29323

File tree

1 file changed

+10
-6
lines changed

1 file changed

+10
-6
lines changed

src/helpers/convertToGenericCoverageReport.ts

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -33,12 +33,16 @@ export function convertToGenericCoverageReport(data: CoverageData, dxDirectory:
3333

3434
for (const coveredLine of coveredLines) {
3535
if (coveredLine > totalLines) {
36-
let randomLineNumber;
37-
do {
38-
randomLineNumber = Math.floor(Math.random() * totalLines) + 1;
39-
} while (coveredLines.includes(randomLineNumber) || uncoveredLines.includes(randomLineNumber) || randomLines.includes(randomLineNumber));
40-
randomLines.push(randomLineNumber);
41-
xml += `\t\t<lineToCover lineNumber="${randomLineNumber}" covered="true"/>\n`;
36+
for (let randomLineNumber = 1; randomLineNumber <= totalLines; randomLineNumber++) {
37+
if (
38+
!uncoveredLines.includes(randomLineNumber) &&
39+
!coveredLines.includes(randomLineNumber) &&
40+
!randomLines.includes(randomLineNumber)
41+
) {
42+
xml += `\t\t<lineToCover lineNumber="${randomLineNumber}" covered="true"/>\n`;
43+
randomLines.push(randomLineNumber);
44+
}
45+
}
4246
} else {
4347
xml += `\t\t<lineToCover lineNumber="${coveredLine}" covered="true"/>\n`;
4448
}

0 commit comments

Comments
 (0)