Phase 3 : hardening qualite de code - typage strict, securite, dead code, a11y

Config strictement stricte partout (ruff, mypy --strict, bandit, vulture,
import-linter, eslint, stylelint), aucune regle desactivee "pour ne pas
casser le build" - l'existant a ete corrige pour la satisfaire plutot que
l'inverse. Hooks pre-commit locaux (language: system) bloquants.

- Typage mypy --strict propage a tout le moteur (db, screens, auth, core,
  ai, routes, puis publish/scripts/tests/app.py/build_css.py).
- Securite : fuite de handle fichier Windows corrigee dans l'export SCORM
  (routes/publish/export_scorm.py), CSRF/RNG non-crypto/xAPI documentes
  (# nosec, # NOSONAR justifies), nouveau db.json_for_script() (echappe
  "</script>" dans le JSON embarque en <script>, 25 sites).
- Architecture : imports circulaires/F811 nettoyes, contrats
  import-linter respectes, code mort retire (vulture).
- Accessibilite : 69 champs de formulaire sans label correctement
  associe corriges (for/id ou aria-label) sur 11 templates.
- ESLint/Stylelint : lot mecanique JS/CSS, regles ajustees puis
  appliquees (aucune desactivee sans verification individuelle).
- Tests : isolation du compte admin partage (nettoyage ponctuel +
  fixture de teardown automatique en filet de securite), suite complete
  verte (591 tests Python, 241 tests JS).
- SonarQube Community Build self-heberge (Docker + PostgreSQL) : rapport
  complet analyse point par point, faux positifs documentes.
- .gitattributes ajoute (LF force) : core.autocrlf=true sur cette machine
  faisait echouer ESLint (linebreak-style) via un bug connu de git
  (checkout "en place" qui ignore l'eol force sur un fichier deja
  present sur disque - contourne en supprimant puis recreant chaque
  fichier suivi).

djLint (H021, styles inline) volontairement saute pour ce commit -
backlog assume, deja documente, traite dans un lot separe.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
william
2026-09-15 16:06:15 +02:00
co-authored by Claude Sonnet 5
parent 7db4803b93
commit c57420c8c9
454 changed files with 16448 additions and 6967 deletions
+28 -28
View File
@@ -7,61 +7,61 @@
// besoin d'un bouton "Enregistrer" séparé (demande explicite : "que la
// modification s'enregistre automatiquement").
function saveGlobalVariable(varId) {
var row = document.querySelector('tr[data-var-row="' + varId + '"]');
const row = document.querySelector(`tr[data-var-row="${varId}"]`);
if (!row) return;
var type = row.querySelector('select[name="type"]').value;
var value = row.querySelector('input[name="value"]').value;
var status = document.getElementById('varSaveStatus' + varId);
var body = new FormData();
const type = row.querySelector('select[name="type"]').value;
const { value } = row.querySelector('input[name="value"]');
const status = document.getElementById(`varSaveStatus${varId}`);
const body = new FormData();
body.append('type', type);
body.append('value', value);
fetch('/game/' + GAME_SLUG + '/variables/' + varId + '/edit', {
method: 'POST', headers: { 'X-Requested-With': 'fetch' }, body: body,
fetch(`/game/${GAME_SLUG}/variables/${varId}/edit`, {
method: 'POST', headers: { 'X-Requested-With': 'fetch' }, body,
})
.then(function (r) {
.then((r) => {
if (!r.ok) { window.location.reload(); return; }
if (status) {
status.textContent = 'Enregistré ✓';
setTimeout(function () { status.textContent = ''; }, 2000);
setTimeout(() => { status.textContent = ''; }, 2000);
}
})
.catch(function () { window.location.reload(); });
.catch(() => { window.location.reload(); });
}
function deleteGlobalVariable(varId, name) {
if (!confirm('Supprimer la variable « ' + name + ' » ? Toute condition/action qui la référence encore cessera de fonctionner.')) return;
var body = new FormData();
fetch('/game/' + GAME_SLUG + '/variables/' + varId + '/delete', {
method: 'POST', headers: { 'X-Requested-With': 'fetch' }, body: body,
if (!window.confirm(`Supprimer la variable « ${name} » ? Toute condition/action qui la référence encore cessera de fonctionner.`)) return;
const body = new FormData();
fetch(`/game/${GAME_SLUG}/variables/${varId}/delete`, {
method: 'POST', headers: { 'X-Requested-With': 'fetch' }, body,
})
.then(function (r) {
.then((r) => {
if (!r.ok) { window.location.reload(); return; }
var row = document.querySelector('tr[data-var-row="' + varId + '"]');
const row = document.querySelector(`tr[data-var-row="${varId}"]`);
if (row) row.remove();
var body2 = document.getElementById('globalVariablesBody');
var emptyHint = document.getElementById('globalVariablesEmptyHint');
const body2 = document.getElementById('globalVariablesBody');
const emptyHint = document.getElementById('globalVariablesEmptyHint');
if (body2 && emptyHint) emptyHint.style.display = body2.children.length ? 'none' : '';
})
.catch(function () { window.location.reload(); });
.catch(() => { window.location.reload(); });
}
function createGlobalVariable(event) {
event.preventDefault();
var form = event.target;
var body = new FormData(form);
fetch('/game/' + GAME_SLUG + '/variables/new', {
method: 'POST', headers: { 'X-Requested-With': 'fetch' }, body: body,
const form = event.target;
const body = new FormData(form);
fetch(`/game/${GAME_SLUG}/variables/new`, {
method: 'POST', headers: { 'X-Requested-With': 'fetch' }, body,
})
.then(function (r) { return r.ok ? r.json() : Promise.reject(); })
.then(function (json) {
.then((r) => (r.ok ? r.json() : Promise.reject()))
.then((json) => {
if (!json.row_html) { window.location.reload(); return; }
var tbody = document.getElementById('globalVariablesBody');
const tbody = document.getElementById('globalVariablesBody');
tbody.insertAdjacentHTML('beforeend', json.row_html);
var emptyHint = document.getElementById('globalVariablesEmptyHint');
const emptyHint = document.getElementById('globalVariablesEmptyHint');
if (emptyHint) emptyHint.style.display = 'none';
form.reset();
form.style.display = 'none'; // même comportement que toggleDashCreate() après création
})
.catch(function () { window.location.reload(); });
.catch(() => { window.location.reload(); });
return false;
}