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:
co-authored by
Claude Sonnet 5
parent
7db4803b93
commit
c57420c8c9
@@ -1,4 +1,5 @@
|
||||
import json
|
||||
from typing import Any
|
||||
|
||||
# Widget d'interface "💬 Boîte de dialogue" (voir "🖥️ Interface",
|
||||
# templates/scene_edit.html, screens/scenes/add_scene_object.py kind=
|
||||
@@ -7,7 +8,7 @@ import json
|
||||
# static/js/play/dialogue-box-controller.js) — header (nom du
|
||||
# personnage qui parle), corps (texte), pied (bouton "Suivant"),
|
||||
# entièrement stylisable par l'auteur.
|
||||
DEFAULT_DIALOGUE_BOX_STYLE = {
|
||||
DEFAULT_DIALOGUE_BOX_STYLE: dict[str, Any] = {
|
||||
"font_family": "inherit",
|
||||
"font_size": 14,
|
||||
"font_weight": "normal",
|
||||
@@ -20,14 +21,17 @@ DEFAULT_DIALOGUE_BOX_STYLE = {
|
||||
FONT_WEIGHT_CHOICES = ["normal", "bold"]
|
||||
|
||||
|
||||
def sanitize_dialogue_box_style(raw_style):
|
||||
def sanitize_dialogue_box_style(raw_style: Any) -> dict[str, Any]:
|
||||
style = dict(DEFAULT_DIALOGUE_BOX_STYLE)
|
||||
if not isinstance(raw_style, dict):
|
||||
return style
|
||||
if isinstance(raw_style.get("font_family"), str) and raw_style["font_family"].strip():
|
||||
style["font_family"] = raw_style["font_family"].strip()[:60]
|
||||
raw_font_size = raw_style.get("font_size")
|
||||
try:
|
||||
style["font_size"] = max(8, min(48, int(raw_style.get("font_size"))))
|
||||
if raw_font_size is None:
|
||||
raise ValueError
|
||||
style["font_size"] = max(8, min(48, int(raw_font_size)))
|
||||
except (TypeError, ValueError):
|
||||
pass
|
||||
if raw_style.get("font_weight") in FONT_WEIGHT_CHOICES:
|
||||
@@ -39,7 +43,7 @@ def sanitize_dialogue_box_style(raw_style):
|
||||
return style
|
||||
|
||||
|
||||
def resolve_dialogue_box_style(obj):
|
||||
def resolve_dialogue_box_style(obj: dict[str, Any]) -> dict[str, Any]:
|
||||
raw = (obj.get("attributes") or {}).get("_dialogue_box_style")
|
||||
if not raw:
|
||||
return dict(DEFAULT_DIALOGUE_BOX_STYLE)
|
||||
|
||||
Reference in New Issue
Block a user