From 3665c2754448c6c967f06166068d3eb51b0d2d99 Mon Sep 17 00:00:00 2001 From: Tyler Karaszewski Date: Tue, 30 Aug 2022 21:50:12 +0200 Subject: [PATCH 1/3] This seems to work with one round of testing --- src/libs/ReportUtils.js | 23 +---------------------- 1 file changed, 1 insertion(+), 22 deletions(-) diff --git a/src/libs/ReportUtils.js b/src/libs/ReportUtils.js index ce3ac2f962eb..d42a2c2c9d46 100644 --- a/src/libs/ReportUtils.js +++ b/src/libs/ReportUtils.js @@ -524,28 +524,7 @@ function navigateToDetailsPage(report) { * @returns {Number} */ function generateReportID() { - // Generate a random 32-bit number. This works fine, and starts us building a random 53-bit number. - let result = Math.floor(Math.random() * (2 ** 32)); - - // Now generate another random number. We'll use this for the remaining 21 bits of randomness. - let extraBits = Math.floor(Math.random() * (2 ** 32)); - - // Add each of the remaining 21 bits to the end of `result`. - for (let i = 0; i < 21; i++) { - // Shift left by one, but don't use bit shifts: they truncate to 32-bits. - result *= 2; - - // If extraBits is odd, meaning the lowest bit is set, do the same to the result, without bitwise operators. - if (extraBits % 2 === 1) { - result += 1; - } - - // Now drop the lowest bit from extraBits, which we can do with bitwise operators, because it's less than 32-bits. - // eslint-disable-next-line no-bitwise - extraBits >>= 1; - } - - return result; + return Math.floor(Math.random() * (2**21)) * (2**32) + Math.floor(Math.random() * (2**32)); } /** From 57debb2f692522a4604322c975901f20e04628e3 Mon Sep 17 00:00:00 2001 From: Tyler Karaszewski Date: Tue, 30 Aug 2022 21:59:06 +0200 Subject: [PATCH 2/3] Appease the linter --- src/libs/ReportUtils.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/libs/ReportUtils.js b/src/libs/ReportUtils.js index d42a2c2c9d46..2638bd726c22 100644 --- a/src/libs/ReportUtils.js +++ b/src/libs/ReportUtils.js @@ -524,7 +524,7 @@ function navigateToDetailsPage(report) { * @returns {Number} */ function generateReportID() { - return Math.floor(Math.random() * (2**21)) * (2**32) + Math.floor(Math.random() * (2**32)); + return (Math.floor(Math.random() * (2**21)) * (2**32)) + Math.floor(Math.random() * (2**32)); } /** From 73071fd10ac163b9920701dc1d1bde01719083bd Mon Sep 17 00:00:00 2001 From: Tyler Karaszewski Date: Tue, 30 Aug 2022 21:59:45 +0200 Subject: [PATCH 3/3] Appease the linter --- src/libs/ReportUtils.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/libs/ReportUtils.js b/src/libs/ReportUtils.js index 2638bd726c22..9dc4158537f0 100644 --- a/src/libs/ReportUtils.js +++ b/src/libs/ReportUtils.js @@ -524,7 +524,7 @@ function navigateToDetailsPage(report) { * @returns {Number} */ function generateReportID() { - return (Math.floor(Math.random() * (2**21)) * (2**32)) + Math.floor(Math.random() * (2**32)); + return (Math.floor(Math.random() * (2 ** 21)) * (2 ** 32)) + Math.floor(Math.random() * (2 ** 32)); } /**