diff --git a/README.md b/README.md index 68af8f1..ed2594b 100644 --- a/README.md +++ b/README.md @@ -19,13 +19,22 @@ flutter --version Android uniquement. -## Lancer les tests +## Vérification qualité (avant de cocher une étape) + +```bash +tool/check.sh +``` + +Le script enchaîne `dart format --set-exit-if-changed`, `flutter analyze` et `flutter test`. +Il échoue (exit ≠ 0) dès qu'une vérification ne passe pas. **`tool/check.sh` doit passer avant de cocher une étape dans `ROADMAP.md`.** + +## Lancer les tests seuls ```bash flutter test ``` -## Analyser le code +## Analyser le code seul ```bash flutter analyze diff --git a/ROADMAP.md b/ROADMAP.md index ce92823..b36dd9d 100644 --- a/ROADMAP.md +++ b/ROADMAP.md @@ -30,7 +30,7 @@ Spec détaillée : [`docs/specs/`](docs/specs/) — un dossier par jalon, étape Spec : [`docs/specs/jalon-0-fondations/`](docs/specs/jalon-0-fondations/) - [x] 0.1 — Structure du projet Flutter & arborescence clean archi (2026-06-19) -- [ ] 0.2 — Outillage qualité (lint strict, format, CI locale) +- [x] 0.2 — Outillage qualité (lint strict, format, CI locale) (2026-06-19) - [ ] 0.3 — Socle transverse (`Result`, erreurs, thème, router, DI Riverpod) ## Jalon 1 — Verrouillage / épinglage ⚠️ diff --git a/analysis_options.yaml b/analysis_options.yaml index 0d29021..7f51b65 100644 --- a/analysis_options.yaml +++ b/analysis_options.yaml @@ -1,28 +1,33 @@ -# This file configures the analyzer, which statically analyzes Dart code to -# check for errors, warnings, and lints. -# -# The issues identified by the analyzer are surfaced in the UI of Dart-enabled -# IDEs (https://dart.dev/tools#ides-and-editors). The analyzer can also be -# invoked from the command line by running `flutter analyze`. - -# The following line activates a set of recommended lints for Flutter apps, -# packages, and plugins designed to encourage good coding practices. +# Analyse statique Storytime — durcissement au-dessus de flutter_lints. +# Objectif : 0 warning sur l'ensemble du projet. +# Pour désactiver une règle localement : // ignore: nom_de_la_regle +# Pour désactiver une règle sur un fichier : // ignore_for_file: nom_de_la_regle include: package:flutter_lints/flutter.yaml -linter: - # The lint rules applied to this project can be customized in the - # section below to disable rules from the `package:flutter_lints/flutter.yaml` - # included above or to enable additional rules. A list of all available lints - # and their documentation is published at https://dart.dev/lints. - # - # Instead of disabling a lint rule for the entire project in the - # section below, it can also be suppressed for a single line of code - # or a specific dart file by using the `// ignore: name_of_lint` and - # `// ignore_for_file: name_of_lint` syntax on the line or in the file - # producing the lint. - rules: - # avoid_print: false # Uncomment to disable the `avoid_print` rule - # prefer_single_quotes: true # Uncomment to enable the `prefer_single_quotes` rule +analyzer: + language: + strict-casts: true + strict-inference: true + strict-raw-types: true -# Additional information about this file can be found at -# https://dart.dev/guides/language/analysis-options +linter: + rules: + # --- Qualité générale --- + always_declare_return_types: true + avoid_print: true # utiliser un logger plutôt que print + require_trailing_commas: true # lisibilité des arguments multi-lignes + prefer_const_constructors: true + prefer_const_declarations: true + prefer_final_locals: true + prefer_single_quotes: true # cohérence : guillemets simples partout + + # --- Robustesse --- + always_use_package_imports: true # pas d'imports relatifs entre features + cancel_subscriptions: true + close_sinks: true + unawaited_futures: true + + # --- Style Flutter --- + use_key_in_widget_constructors: true + sized_box_for_whitespace: true + prefer_const_constructors_in_immutables: true diff --git a/pubspec.lock b/pubspec.lock index 2418a71..5afafdf 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -131,6 +131,14 @@ packages: url: "https://pub.dev" source: hosted version: "1.17.0" + mocktail: + dependency: "direct dev" + description: + name: mocktail + sha256: "5e1bf53cc7baa8062a33b84424deb61513858ea05c601b8509e683815b5914aa" + url: "https://pub.dev" + source: hosted + version: "1.0.5" path: dependency: transitive description: diff --git a/pubspec.yaml b/pubspec.yaml index fc4aff4..c5dc3d9 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -37,12 +37,8 @@ dev_dependencies: flutter_test: sdk: flutter - # The "flutter_lints" package below contains a set of recommended lints to - # encourage good coding practices. The lint set provided by the package is - # activated in the `analysis_options.yaml` file located at the root of your - # package. See that file for information about deactivating specific lint - # rules and activating additional ones. flutter_lints: ^6.0.0 + mocktail: ^1.0.4 # For information on the generic Dart part of this file, see the # following page: https://dart.dev/tools/pub/pubspec diff --git a/tool/check.sh b/tool/check.sh new file mode 100755 index 0000000..e5f90ea --- /dev/null +++ b/tool/check.sh @@ -0,0 +1,21 @@ +#!/usr/bin/env bash +# CI locale Storytime — à passer avant de cocher une étape dans ROADMAP.md. +# Échoue (exit non nul) dès qu'une vérification ne passe pas. +set -euo pipefail + +cd "$(dirname "$0")/.." + +command -v flutter >/dev/null 2>&1 || { echo "flutter absent du PATH"; exit 1; } +command -v dart >/dev/null 2>&1 || { echo "dart absent du PATH"; exit 1; } + +echo "==> dart format" +dart format --set-exit-if-changed . + +echo "==> flutter analyze" +flutter analyze + +echo "==> flutter test" +flutter test + +echo "" +echo "Tout est vert."