Skip to content

[flutter_tools] Migrate analysis_options.yaml to exclude build and platform directories by default#187940

Merged
auto-submit[bot] merged 6 commits into
flutter:masterfrom
bkonyi:migrate-analysis-exclude-build
Jun 23, 2026
Merged

[flutter_tools] Migrate analysis_options.yaml to exclude build and platform directories by default#187940
auto-submit[bot] merged 6 commits into
flutter:masterfrom
bkonyi:migrate-analysis-exclude-build

Conversation

@bkonyi

@bkonyi bkonyi commented Jun 12, 2026

Copy link
Copy Markdown
Contributor

This PR:

  • Updates the default analysis_options.yaml templates for new apps, modules, packages, and plugins to exclude the build/ and platform-specific directories (android/, ios/, web/, windows/, macos/, linux/) by default.
  • Implements AnalysisOptionsMigration to automatically migrate analysis_options.yaml files of existing projects using package:yaml_edit to preserve comments and formatting.
  • Integrates the migration into FlutterProject.ensureReadyForPlatformSpecificTooling so it runs globally for most commands, including flutter run, flutter build, and flutter analyze.
  • Adds unit tests for the migration.

Fixes #187728

…atform directories by default

This change:
- Updates the default analysis_options.yaml templates for new apps, modules, packages, and plugins to exclude the build/ and platform-specific directories (android, ios, web, windows, macos, linux) by default.
- Implements `AnalysisOptionsMigration` to automatically migrate existing projects' analysis_options.yaml files using `package:yaml_edit` to preserve comments and formatting.
- Integrates the migration into `FlutterProject.ensureReadyForPlatformSpecificTooling` so it runs globally for most commands, including `flutter run`, `flutter build`, and `flutter analyze`.
- Adds unit tests for the migration.

Fixes flutter#187728
@flutter-dashboard flutter-dashboard Bot added the CICD Run CI/CD label Jun 12, 2026
@github-actions github-actions Bot added the tool Affects the "flutter" command-line tool. See also t: labels. label Jun 12, 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 introduces AnalysisOptionsMigration to automatically update analysis_options.yaml files, excluding build and platform-specific directories. It also updates project templates to include these exclusions by default and adds corresponding unit tests. Feedback suggests optimizing the migration by declaring the list of excluded directories as a constant and using editor.appendIntoList to preserve existing comments and formatting in the YAML file.

Comment thread packages/flutter_tools/lib/src/migrations/analysis_options_migration.dart Outdated
Comment thread packages/flutter_tools/lib/src/migrations/analysis_options_migration.dart Outdated
Addresses feedback from gemini-code-assist bot:
- Makes `excludesToExclude` a const list.
- Uses `YamlEditor.appendToList` instead of `update` to preserve comments inside the exclude list.
- Adds a unit test to verify comment preservation.
@github-actions github-actions Bot removed the CICD Run CI/CD label Jun 12, 2026
@bkonyi bkonyi added the CICD Run CI/CD label Jun 12, 2026
@bkonyi
bkonyi requested a review from vashworth June 12, 2026 18:48
Addresses reviewer feedback by adding a unit test to verify that `AnalysisOptionsMigration` correctly handles and merges excludes when the `exclude` list in `analysis_options.yaml` is formatted in flow style (inline brackets, e.g., `[a, b]`).

Thanks to `package:yaml_edit`, this is handled automatically.
@github-actions github-actions Bot removed the CICD Run CI/CD label Jun 19, 2026
…ained

Addresses reviewer feedback by removing `setUp` and group-level state variables in `analysis_options_migration_test.dart` to make each test entirely self-contained, as per the Flutter Style Guide.

To avoid repeating the setup boilerplate in all 9 tests while remaining lint-compliant, this refactoring:
- Introduces a `_TestContext` named record `typedef` to hold the test dependencies.
- Introduces a private helper `_createTestContext()` that returns a fresh record instance for each test.
- Initializes the context locally in each test using `final _TestContext context = _createTestContext();`.
This satisfies the `specify_nonobvious_local_variable_types` lint with a single type annotation per test.
@flutter-dashboard flutter-dashboard Bot added the CICD Run CI/CD label Jun 19, 2026
…clude-build

# Conflicts:
#	packages/flutter_tools/lib/src/project.dart
@github-actions github-actions Bot removed the CICD Run CI/CD label Jun 19, 2026
@bkonyi bkonyi added the CICD Run CI/CD label Jun 19, 2026
@bkonyi
bkonyi requested a review from vashworth June 22, 2026 16:34
@bkonyi bkonyi added the autosubmit Merge PR when tree becomes green via auto submit App label Jun 23, 2026
@auto-submit auto-submit Bot removed the autosubmit Merge PR when tree becomes green via auto submit App label Jun 23, 2026
@auto-submit

auto-submit Bot commented Jun 23, 2026

Copy link
Copy Markdown
Contributor

auto label is removed for flutter/flutter/187940, Failed to enqueue flutter/flutter/187940 with HTTP 400: Pull request Required status check "Check Code Freeze" is in progress..

@github-actions github-actions Bot removed the CICD Run CI/CD label Jun 23, 2026
@bkonyi bkonyi added autosubmit Merge PR when tree becomes green via auto submit App CICD Run CI/CD labels Jun 23, 2026
@auto-submit auto-submit Bot removed the autosubmit Merge PR when tree becomes green via auto submit App label Jun 23, 2026
@auto-submit

auto-submit Bot commented Jun 23, 2026

Copy link
Copy Markdown
Contributor

autosubmit label was removed for flutter/flutter/187940, because - The status or check suite Windows tool_integration_tests_10_10 has failed. Please fix the issues identified (or deflake) before re-applying this label.

@bkonyi bkonyi added the autosubmit Merge PR when tree becomes green via auto submit App label Jun 23, 2026
@auto-submit
auto-submit Bot added this pull request to the merge queue Jun 23, 2026
Merged via the queue into flutter:master with commit 11e339e Jun 23, 2026
175 checks passed
@flutter-dashboard flutter-dashboard Bot removed the autosubmit Merge PR when tree becomes green via auto submit App label Jun 23, 2026
via-guy pushed a commit to via-guy/flutter that referenced this pull request Jun 26, 2026
…atform directories by default (flutter#187940)

This PR:
- Updates the default `analysis_options.yaml` templates for new apps,
modules, packages, and plugins to exclude the `build/` and
platform-specific directories (`android/`, `ios/`, `web/`, `windows/`,
`macos/`, `linux/`) by default.
- Implements `AnalysisOptionsMigration` to automatically migrate
`analysis_options.yaml` files of existing projects using
`package:yaml_edit` to preserve comments and formatting.
- Integrates the migration into
`FlutterProject.ensureReadyForPlatformSpecificTooling` so it runs
globally for most commands, including `flutter run`, `flutter build`,
and `flutter analyze`.
- Adds unit tests for the migration.

Fixes flutter#187728
auto-submit Bot pushed a commit to flutter/packages that referenced this pull request Jun 29, 2026
…12041)

Manual roll requested by [email protected]

flutter/flutter@87224e0...11e339e

2026-06-23 [email protected] [flutter_tools] Migrate analysis_options.yaml to exclude build and platform directories by default (flutter/flutter#187940)
2026-06-23 [email protected] Update docs for PR limits (flutter/flutter#188388)
2026-06-23 [email protected] Roll Packages from cd5194a to 7d84a69 (4 revisions) (flutter/flutter#188383)
2026-06-23 [email protected] [Tool] Fix widget-preview crash by waiting for analysis server (flutter/flutter#187941)

If this roll has caused a breakage, revert this CL and stop the roller
using the controls here:
https://autoroll.skia.org/r/flutter-packages
Please CC [email protected],[email protected] on the revert to ensure that a human
is aware of the problem.

To file a bug in Packages: https://github.com/flutter/flutter/issues/new/choose

To report a problem with the AutoRoller itself, please file a bug:
https://issues.skia.org/issues/new?component=1389291&template=1850622

Documentation for the AutoRoller is here:
https://skia.googlesource.com/buildbot/+doc/main/autoroll/README.md
adil192 added a commit to saber-notes/saber that referenced this pull request Jul 1, 2026
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.

Proposal:flutter create templates should exclude the build (and other appropriate) folders from analysis

2 participants