Skip to content

Fix flaky Windows dart analyze; enforce dart_code_linter on test/#145

Merged
reidbaker merged 3 commits into
flutter:mainfrom
reidbaker:r-fix-flaky-windows-analyze
May 22, 2026
Merged

Fix flaky Windows dart analyze; enforce dart_code_linter on test/#145
reidbaker merged 3 commits into
flutter:mainfrom
reidbaker:r-fix-flaky-windows-analyze

Conversation

@reidbaker
Copy link
Copy Markdown
Contributor

@reidbaker reidbaker commented May 22, 2026

Fixes #144 — the analyze_and_test (windows-latest) job intermittently failed at dart analyze --fatal-infos, reporting dart_code_linter warnings (each duplicated) against pre-existing test files, while the same commit passed on Linux/macOS and locally.

Root cause

1.) analysis_options.yaml registered dart_code_linter as an analyzer plugin.
1.) With that registration, dart analyze loads the plugin in a separate isolate that re-emits the dart_code_linter: rules as diagnostics over the plugin protocol, across all non-excluded files (including test/).
1.) Delivery of those diagnostics back to the dart analyze CLI 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-infos fails), sometimes they don't.
FYI Linux/macOS land on the clean side consistently.

What changed

  • No longer use plugin registration. dart analyze now enforces only core lints.
  • Extend dart_code_linter workflow to test.
  • Fix the test-file violations this surfaces but exclude some rules for test/**

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.
Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment thread tool/dart_skills_lint/analysis_options.yaml
Comment thread tool/dart_skills_lint/test/absolute_paths_test.dart Outdated
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).
Comment thread tool/dart_skills_lint/analysis_options.yaml Outdated
@reidbaker reidbaker merged commit 5519cc0 into flutter:main May 22, 2026
12 checks passed
@reidbaker reidbaker deleted the r-fix-flaky-windows-analyze branch May 22, 2026 13:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Flaky CI: analyze_and_test (windows-latest) intermittently fails on `dart analyze --fatal-infos

1 participant