[flutter_tools] Migrate analysis_options.yaml to exclude build and platform directories by default#187940
Conversation
…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
There was a problem hiding this comment.
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.
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.
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.
…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.
…clude-build # Conflicts: # packages/flutter_tools/lib/src/project.dart
|
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.. |
|
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. |
…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
…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
Added upstream in Flutter: flutter/flutter#187940
This PR:
analysis_options.yamltemplates for new apps, modules, packages, and plugins to exclude thebuild/and platform-specific directories (android/,ios/,web/,windows/,macos/,linux/) by default.AnalysisOptionsMigrationto automatically migrateanalysis_options.yamlfiles of existing projects usingpackage:yaml_editto preserve comments and formatting.FlutterProject.ensureReadyForPlatformSpecificToolingso it runs globally for most commands, includingflutter run,flutter build, andflutter analyze.Fixes #187728