Skip to content

fix: flutter analyze reporting the same issue multiple times - #193279

Merged
auto-submit[bot] merged 2 commits into
flutter:masterfrom
rkishan516:analyze-duplicate-diagnostics
Sep 24, 2026
Merged

auto-submit[bot] merged 2 commits into
flutter:masterfrom
rkishan516:analyze-duplicate-diagnostics

Conversation

@rkishan516

Copy link
Copy Markdown
Contributor

This PR fixes flutter analyze reporting the same issue multiple times.

The analysis server sends the complete list of diagnostics for a file in a textDocument/publishDiagnostics notification, and publishes the file again whenever that list changes, for example once for the Dart analysis results and again when an analyzer plugin reports for it. AnalyzeOnce appended the errors from every notification, so an issue in a file that was published three times was reported three times.

This change keeps only the latest diagnostics for each file, the same way AnalyzeContinuously already does, and adds a test that publishes diagnostics for the same file twice.

Fixes: #192587

Pre-launch Checklist

The language server republishes a file's full set of diagnostics whenever
they change, e.g. when an analyzer plugin reports after the Dart analysis
results. AnalyzeOnce appended every publish, so a file published N times
had its issues reported N times. Keep only the latest set per file, as
AnalyzeContinuously already does.

Fixes: flutter#192587
@flutter-dashboard flutter-dashboard Bot added the CICD Run CI/CD label Sep 24, 2026
@github-actions github-actions Bot added the tool Affects the "flutter" command-line tool. See also t: labels. label Sep 24, 2026

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

Copy link
Copy Markdown
Contributor

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 updates the analysis error handling in 'analyze_once.dart' by using a map to store errors by file, ensuring that only the latest diagnostics are reported. A corresponding test case has been added to 'analyze_test.dart' to verify this behavior. The reviewer suggested renaming the closure parameter in the 'expand' method to 'fileErrors' to avoid shadowing the outer 'errors' variable and to improve code readability.

Comment thread packages/flutter_tools/lib/src/commands/analyze_once.dart Outdated
@bkonyi
bkonyi requested review from bkonyi and srawlins September 24, 2026 20:37

@bkonyi bkonyi left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This LGTM, but can you verify @srawlins?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CICD Run CI/CD tool Affects the "flutter" command-line tool. See also t: labels.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Framework analyzer plugins report the same violation multiple times

3 participants