Linting, tests, README, CI, and code quality improvements

Linting:
- analysis_options.yaml: flutter_lints base + 20 additional rules
  (prefer_single_quotes, avoid_print, cancel_subscriptions,
  unawaited_futures, empty_catches, always_declare_return_types, …)
- unused_import / dead_code treated as errors

pubspec.yaml:
- Remove 6 unused packages: freezed, freezed_annotation, json_annotation,
  json_serializable, riverpod_generator, collection
- Add test: ^1.25.0 for pure-Dart unit tests

Testable utilities (extracted from screen code):
- lib/core/utils/html_utils.dart — htmlToPlain()
- lib/core/utils/format_utils.dart — fmtSize()
- lib/core/utils/logger.dart — thin debugPrint wrapper

Unit tests (test/unit/, no device required):
- html_utils_test.dart — 13 cases covering tags, entities, edge cases
- format_utils_test.dart — B / KB / MB / GB formatting
- email_model_test.dart — EmailAddress JSON roundtrip, toString, EmailDraft
- account_sync_backoff_test.dart — exponential backoff + clamping

Taskfile:
- task test → dart test test/unit/ (fast, no device)
- task test-flutter → flutter test (widget tests)
- task check → analyze + unit tests in parallel

README rewrite:
- Covers user flow (download, add account)
- Developer flow: nix develop, direnv allow, task codegen, task check
- Platform status table (Linux done, others pending)
- Project layout diagram
- Schema-change workflow

CI (.github/workflows/ci.yml):
- analyze-and-test job: flutter analyze + dart test on every push/PR
- integration job: Nix + Stalwart on push to main
- build-linux job: flutter build linux --release

Logging:
- Replace all bare catch (_) {} with log() calls
- Sync backoff errors now print account email + retry delay
- STATUS failures on \Noselect mailboxes logged at debug level
- STARTTLS failures logged before continuing without TLS

.gitignore:
- Add .direnv/, .flutter-plugins-dependencies
- Add all platform generated-plugin wiring files
- Add .env / .env.local
- Add linux/build/

.env.example: documents optional STALWART_PORT overrides

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
Thomas Güttler
2026-04-16 08:11:29 +02:00
co-authored by Claude Sonnet 4.6
parent 72e2b599bf
commit 03d35387f7
18 changed files with 576 additions and 54 deletions
+17 -7
View File
@@ -2,7 +2,7 @@ version: "3"
tasks:
default:
desc: Run all checks (analyze + test, in parallel)
desc: Run all checks (analyze + unit tests, in parallel)
deps: [check]
_nix-check:
@@ -13,7 +13,7 @@ tasks:
msg: "Not in nix dev shell. Run: nix develop"
codegen:
desc: Run build_runner to generate Drift and Riverpod code
desc: Generate Drift DB code (run after any schema change)
deps: [_nix-check]
cmds:
- |
@@ -23,7 +23,7 @@ tasks:
echo "codegen: $((END - START))s"
analyze:
desc: Run flutter analyze
desc: Static analysis with flutter analyze + analysis_options.yaml rules
deps: [_nix-check]
cmds:
- |
@@ -33,20 +33,30 @@ tasks:
echo "analyze: $((END - START))s"
analyze-fix:
desc: Auto-fix with dart fix --apply
desc: Auto-fix lint issues with dart fix --apply
deps: [_nix-check]
cmds:
- dart fix --apply
test:
desc: Run unit tests
desc: Run pure-Dart unit tests (no device needed)
deps: [_nix-check]
cmds:
- |
START=$(date +%s)
dart test test/unit/
END=$(date +%s)
echo "test: $((END - START))s"
test-flutter:
desc: Run Flutter widget tests
deps: [_nix-check]
cmds:
- |
START=$(date +%s)
flutter test
END=$(date +%s)
echo "test: $((END - START))s"
echo "flutter test: $((END - START))s"
integration:
desc: Run integration tests (starts and stops Stalwart automatically)
@@ -65,5 +75,5 @@ tasks:
- flutter run -d linux
check:
desc: All checks — analyze + unit tests in parallel
desc: All fast checks — analyze + unit tests in parallel
deps: [analyze, test]