cleanup and fix sonarqube findings
Sonarqube Scanner / Build and analyze (push) Successful in 51s

This commit is contained in:
ChatGPT
2026-06-04 23:54:22 +02:00
parent d7ce563925
commit dd1b08ee21
5 changed files with 54 additions and 19 deletions
+13 -2
View File
@@ -1,6 +1,6 @@
export function randomPointInCircle(origin, radiusPx) {
const angle = Math.random() * Math.PI * 2;
const distance = Math.sqrt(Math.random()) * radiusPx;
const angle = randomUnitFloat() * Math.PI * 2;
const distance = Math.sqrt(randomUnitFloat()) * radiusPx;
return {
x: origin.x + Math.cos(angle) * distance,
@@ -19,3 +19,14 @@ export function sceneDistanceToPixels(distance) {
const distancePerGrid = canvas.scene.grid.distance || 5;
return distance / distancePerGrid * gridSize;
}
function randomUnitFloat() {
const cryptoApi = globalThis.crypto;
if (!cryptoApi?.getRandomValues) {
throw new Error("A cryptographically secure random generator is not available.");
}
const values = new Uint32Array(1);
cryptoApi.getRandomValues(values);
return values[0] / 0x100000000;
}