ci: harden static analysis (strict casts + null/async lints) + FD-limit fix#663
ci: harden static analysis (strict casts + null/async lints) + FD-limit fix#663joshuakrueger-dfx wants to merge 2 commits into
Conversation
TaprootFreak
left a comment
There was a problem hiding this comment.
Requesting changes — wrong base branch (blocks merge).
This PR targets develop directly with a feature branch (ci/harden-analysis-and-coverage). Per CONTRIBUTING.md → Branch Flow:
All feature PRs target
staging, notdevelop.
Merging here bypasses the staging integration gate. Please retarget/rebase onto staging; the change then reaches develop via the existing auto-staging-pr.yaml promotion. Everything below is non-blocking — the code itself reviewed cleanly.
Code (LOW / behaviour-preserving — verified against the branch source):
- DFX JSON casts (
dfx_price_service.dart, thedfx_*services): the new explicit casts only change the exception type (TypeErrorvsNoSuchMethodError) and move the throw one line earlier. No previously-tolerated API response becomes a new crash, and noas Stringwas applied to a field the API legitimately returns as null. Crash surface unchanged. dfx_auth_service.dart403 branch: a non-object body now throws at the cast, but it's an error path that throws anExceptiontwo lines later regardless. Cosmetic.unawaited(...)additions: each wrapped call was already a bare un-awaited future — no ordering/race/error-handling behaviour changed.
Suggestions (non-blocking):
- Consider dropping
--fatal-infosand keeping only--fatal-warnings. The targeted bug classes (unguarded casts, unawaited futures, dynamic calls) are already warnings/errors under the newstrict-*modes.--fatal-infoswill hard-red every PR whenever a future Flutter/lint SDK bump introduces a new info-level lint — the noisiest, churniest tier. ulimit -n 16384is a fine pragmatic CI fix, but 2.3k tests exhausting the macOS default (256) suggests FDs aren't released promptly (coverage instrumentation + unclosedHttpClient/streams). Worth a follow-up issue for the leak rather than only raising the limit.
Nice work fixing the lints by hand with no // ignore:.
|
To be explicit and on the record: this must not happen again. Every feature PR — including CI/tooling/chore branches like this one — targets Please retarget this PR onto |
|
Update — the following two items are now required before merge (upgrading them from the non-blocking suggestions in my review above):
Both are part of the requested changes — please address them together with the |
…-infos/-warnings, FD-limit fix for coverage
The targeted bug classes (unguarded casts, unawaited futures, dynamic calls) already fail under the new strict-* modes and warning-level lints. --fatal-infos would hard-red every PR on future SDK/lint bumps that add new info-level lints — the noisiest tier — for no extra bug coverage.
da10c87 to
64382b4
Compare
|
@TaprootFreak Blocker + Vorschlag 1 adressiert:
CI läuft auf der neuen Base neu an. |
Why
The Big Brother audit (#657) surfaced 189 findings; a large share of the code-bug class (unguarded casts/null access leading to RangeError crashes, fire-and-forget futures behind async/race bugs, dynamic calls) is statically catchable but slips through today because the analyzer runs with only base
flutter_lintsand a non-fatalflutter analyze.This PR hardens the static-analysis gate so those classes fail the build going forward — at near-zero ongoing cost.
What changed
analysis_options.yaml
analyzer.language:strict-casts,strict-inference,strict-raw-typesunawaited_futures,avoid_dynamic_calls,cast_nullable_to_non_nullable,null_check_on_nullable_type_parameter,unnecessary_null_checks,prefer_final_locals.github/workflows/pull-request.yaml
flutter analyzenow runs with--fatal-infos --fatal-warnings(infos/warnings block)ulimit -n 16384— the macOS default (256) makesflutter test --coveragefail with "Too many open files" once the suite is large enough (reproduced locally at ~2.3k tests)Source/tests (56 files, behaviour-preserving)
jsonDecodesites + per-field casts across the DFX service layerunawaited(...)on genuine fire-and-forget callsFuture<void>,showModalBottomSheet<void>, typedbloc_testexpect lists)dart fix --applyhandled the mechanical subset; the rest by hand. No// ignore:added.Bug classes now caught at CI
qr_address_widgetRangeError)Verification
flutter analyze --fatal-infos --fatal-warnings→ No issues foundflutter test --exclude-tags golden→ all 2296 tests passDeliberately out of scope (follow-ups)
discarded_futures(211 hits, almost all in tests) — noisy, separate PRcoverage-floorgate as a required check + setting a real floor per the README ratchet protocol (scoped coverage is currently 77.1%)custom_lintrules for the recurring HIGH patterns (sell flow using the buy-price endpoint, hardcodedswissTaxResidence, fixed-index addresssubstring)