Lot 4 modernisation JS (SonarLint) + restauration CI sonarqube non-bloquante
Build and deploy / test-python (push) Successful in 11m18s
Build and deploy / test-js (push) Successful in 1m16s
Build and deploy / lint-python (push) Successful in 4m24s
Build and deploy / lint-js (push) Successful in 2m51s
Build and deploy / build-and-push (push) Skipped
Build and deploy / deploy (push) Skipped
Build and deploy / sonarqube (push) Successful in 5m30s

Corrige les findings SonarQube (via SonarLint IDE, fichier par fichier)
sur ~24 fichiers static/js/ : parseFloat/parseInt -> Number.*,
.replace(/x/g,y) -> .replaceAll, .indexOf() -> .includes()/.startsWith(),
getAttribute/setAttribute -> .dataset, tableaux -> Set, x && x.y -> x?.y
(verifie site par site), extraction de template litteraux imbriques,
ternaires imbriquees, refactors de complexite cognitive (S3776) via
tables de dispatch, Object.hasOwn, .at(), et deduplication de fonctions
identiques (S4144). Deux exceptions S2486 documentees/corrigees
(filter-repeater-rows.js) et un cas S2703 de partage inter-scripts
complete (_collisionWizard, trigger-editor.js <-> collision-rules-editor.js).
Details complets dans CODE_QUALITY.md section 5.

Restaure aussi le job CI "sonarqube" (non-bloquant) dans
.gitea/workflows/deploy.yml maintenant que l'instance prod est
operationnelle.

Suites vertes : 276/276 JS (node --test), 591/591 Python (pytest).

SKIP=djlint sur ce commit : hook djlint bloquant sur le backlog H021
(styles inline, 49 occurrences/6 templates) deja documente comme dette
assumee non traitee dans CODE_QUALITY.md section 6, aucun rapport avec
ce commit (aucun template touche ici) - valide explicitement avec
l'utilisateur avant de contourner ce hook.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
william
2026-09-18 16:38:29 +02:00
co-authored by Claude Sonnet 5
parent 66d8eaeae8
commit ccf836f2c5
36 changed files with 1720 additions and 838 deletions
+16 -16
View File
@@ -43,8 +43,8 @@ function compareValues(actual, operator, expected, fieldType) {
const e = normalizeBool(expected);
return operator === 'different' ? a !== e : a === e;
}
const an = parseFloat(actual); const
en = parseFloat(expected);
const an = Number.parseFloat(actual); const
en = Number.parseFloat(expected);
const numeric = !Number.isNaN(an) && !Number.isNaN(en);
if (numeric) {
switch (operator) {
@@ -87,7 +87,7 @@ function compareValues(actual, operator, expected, fieldType) {
// nécessaire ici : le nom de la variable est choisi dans un menu
// déroulant, voir screen_edit.html).
function readVariableValue(name) {
const v = (gameData.variables || {})[name];
const v = gameData.variables?.[name];
return v ? v.value : undefined;
}
@@ -105,7 +105,7 @@ function resolveVariablePath(rawValue, path) {
let m;
while ((m = segmentRe.exec(path)) !== null) {
if (current === null || current === undefined) return null;
current = m[1] !== undefined ? current[m[1]] : current[parseInt(m[2], 10)];
current = m[1] !== undefined ? current[m[1]] : current[Number.parseInt(m[2], 10)];
}
return current === undefined ? null : current;
}
@@ -129,13 +129,13 @@ function resolveVariablePath(rawValue, path) {
// PURE (aucun accès DOM) — testée par static/js/play/__tests__/
// conditions.test.js, contrairement à elementsOverlap() ci-dessous.
function forgeCollisionRectFromBox(box, collision) {
const width = (collision && collision.width) || box.width;
const height = (collision && collision.height) || box.height;
const offsetX = (collision && collision.offset_x) || 0;
const offsetY = (collision && collision.offset_y) || 0;
const width = collision?.width || box.width;
const height = collision?.height || box.height;
const offsetX = collision?.offset_x || 0;
const offsetY = collision?.offset_y || 0;
const left = box.left + (box.width - width) / 2 + offsetX;
const top = box.top + (box.height - height) / 2 + offsetY;
const shape = (collision && collision.shape) || 'rectangle';
const shape = collision?.shape || 'rectangle';
return {
left, top, right: left + width, bottom: top + height, width, height, shape,
};
@@ -156,7 +156,7 @@ function forgeCirclesOverlap(a, b) {
br = Math.min(b.width, b.height) / 2;
const dx = acx - bcx; const
dy = acy - bcy;
return Math.sqrt(dx * dx + dy * dy) < (ar + br);
return Math.hypot(dx, dy) < (ar + br);
}
// Choisit rectangle-rectangle ou cercle-cercle selon la forme des DEUX
@@ -190,13 +190,13 @@ function elementsOverlap(elementIdA, elementIdB) {
const objA = screenData && (screenData.elements || []).find((o) => o.id === elementIdA);
const objB = screenData && (screenData.elements || []).find((o) => o.id === elementIdB);
if (
(objA && objA.collision && objA.collision.enabled === false)
|| (objB && objB.collision && objB.collision.enabled === false)
objA?.collision?.enabled === false
|| objB?.collision?.enabled === false
) {
return false;
}
const rectA = forgeCollisionRectFromBox(a.getBoundingClientRect(), objA && objA.collision);
const rectB = forgeCollisionRectFromBox(b.getBoundingClientRect(), objB && objB.collision);
const rectA = forgeCollisionRectFromBox(a.getBoundingClientRect(), objA?.collision);
const rectB = forgeCollisionRectFromBox(b.getBoundingClientRect(), objB?.collision);
return forgeShapesOverlap(rectA, rectB);
}
@@ -215,9 +215,9 @@ function evaluateConditionClause(clause) {
if (source === 'variable') {
const varName = clause.variable ?? clause.cond_variable;
const path = clause.variable_chemin ?? clause.cond_variable_chemin;
const varInfo = (gameData.variables || {})[varName];
const varInfo = gameData.variables?.[varName];
const actual = resolveVariablePath(readVariableValue(varName), path);
const fieldType = varInfo && varInfo.type === 'booleen' ? 'booleen' : '';
const fieldType = varInfo?.type === 'booleen' ? 'booleen' : '';
return compareValues(actual, operator, expected, fieldType);
}
const actual = readFieldValue(