Fix flaky Windows dart analyze; enforce dart_code_linter on test/#145
Merged
Conversation
Drop the dart_code_linter analyzer `plugin` registration from analysis_options.yaml. When registered, `dart analyze` loaded the plugin in a separate isolate that re-emitted the `dart_code_linter:` rules as diagnostics over the plugin protocol for all non-excluded files. Delivery of those diagnostics to the CLI is asynchronous and racy, so on slower Windows CI runners they intermittently appeared and `--fatal-infos` turned them fatal -- a flaky, platform-specific failure (flutter#144). `dart analyze` now enforces only core lints, deterministically across platforms. The dedicated `dart run dart_code_linter:metrics` step is the deterministic enforcement path for those rules; extend it to cover `test` as well as `lib` so the test suite gets real, cross-platform coverage instead of the accidental flaky version. Fix the test-file violations this surfaces: - avoid-late-keyword: replace `late Directory tempDir` fixtures with a shared createTempDir() helper that registers cleanup via addTearDown, removing duplicated tearDown blocks. - avoid-dynamic: `dynamic noSuchMethod` -> `Object?`. - avoid-redundant-async: drop the redundant async in a setUp. Exclude prefer-match-file-name for test/**: test files must be named `*_test.dart` and commonly hold several small fixture classes, so they cannot match the rule's "file name == first class name" convention.
Contributor
There was a problem hiding this comment.
Code Review
This pull request refactors the test suite to use a new createTempDir utility that leverages addTearDown for automatic cleanup, and removes the dart_code_linter plugin from the analysis options to resolve CI flakiness. Review feedback suggests that instead of using placeholder initializations for tempDir variables to satisfy the linter, the avoid-late-keyword rule should be disabled for the test directory to allow for more idiomatic late declarations.
Address review feedback: rather than initializing tempDir fixtures to a placeholder to satisfy avoid-late-keyword, exclude the rule for test/** (as already done for prefer-match-file-name). `late` for fields assigned in setUp is the idiomatic Dart test pattern. Reverts the createTempDir helper and placeholder initializations; fixtures are plain `late` again. The genuine, non-late fixes are kept: avoid-dynamic (Object? noSuchMethod) and avoid-redundant-async (drop async from a sync setUp).
reidbaker
commented
May 22, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #144 — the
analyze_and_test (windows-latest)job intermittently failed atdart analyze --fatal-infos, reportingdart_code_linterwarnings (each duplicated) against pre-existing test files, while the same commit passed on Linux/macOS and locally.Root cause
1.)
analysis_options.yamlregistereddart_code_linteras an analyzerplugin.1.) With that registration,
dart analyzeloads the plugin in a separate isolate that re-emits thedart_code_linter:rules as diagnostics over the plugin protocol, across all non-excluded files (includingtest/).1.) Delivery of those diagnostics back to the
dart analyzeCLI is asynchronous and racy. Windows CI runners have much higher timing variance (process/isolate spawn cost, Defender file/exec interception), so the relative ordering of the main analysis vs. plugin delivery flips run-to-run: sometimes the warnings land (→--fatal-infosfails), sometimes they don't.FYI Linux/macOS land on the clean side consistently.
What changed
dart analyzenow enforces only core lints.dart_code_linterworkflow to test.