Skip to content

[stable] Only exclude platform directories that actually exist in analysis_options.yaml - #191530

Open
flutteractionsbot wants to merge 1 commit into
flutter:flutter-3.47-candidate.0from
flutteractionsbot:cp-stable-c7a822e59b5b37c4fa74f0cc71e9d1f4e25ac7ff
Open

[stable] Only exclude platform directories that actually exist in analysis_options.yaml#191530
flutteractionsbot wants to merge 1 commit into
flutter:flutter-3.47-candidate.0from
flutteractionsbot:cp-stable-c7a822e59b5b37c4fa74f0cc71e9d1f4e25ac7ff

Conversation

@flutteractionsbot

@flutteractionsbot flutteractionsbot commented Aug 22, 2026

Copy link
Copy Markdown
Contributor

This pull request is created by automatic cherry pick workflow
Please fill in the form below, and a flutter domain expert will evaluate this cherry pick request.

Issue Link:

#191131

Impact Description:

AnalysisOptionsMigration (shipped in 3.47.0) writes a fixed seven-entry exclude list (android/**, ios/**, web/**, windows/**, macos/**, linux/**, build/**) into analysis_options.yaml on every flutter pub get / analyze / run / build, regardless of which directories the project actually contains. A Dart-only package (e.g. dart create -t web) that uses web/ as a source directory gets it silently excluded from analysis the first time any Flutter command touches the package, and there is no opt-out — the entries are restored on every command.

Changelog Description:

[flutter/191131] Only exclude platform directories that actually exist, so web/** sources in Dart web packages are no longer silently dropped from analysis.

Workaround:

None — every Flutter command that reaches ensureReadyForPlatformSpecificTooling restores the full exclude list; the only way to keep the entries out is to not run Flutter tooling in the package.

Risk:

What is the risk level of this cherry-pick?

  • Low
  • Medium
  • High

Test Coverage:

Are you confident that your fix is well-tested by automated tests?

  • Yes
  • No

Validation Steps:

  1. dart create -t web repro && cd repro && flutter pub get — confirm web/** is not added to the exclude list and dart analyze still reports errors in web/main.dart.
  2. flutter create --platforms=android,ios app — confirm analysis_options.yaml only excludes build/**, android/**, and ios/**.
  3. Run packages/flutter_tools/test/general.shard/migrations/analysis_options_migration_test.dart and packages/flutter_tools/test/commands.shard/permeable/create_test.dart.

…ions.yaml (flutter#191151)

`AnalysisOptionsMigration` wrote a fixed seven-entry `exclude` list
(`android/**`, `ios/**`, `web/**`, `windows/**`, `macos/**`, `linux/**`,
plus `build/**`) into `analysis_options.yaml` on every `flutter pub get`
/ `flutter analyze` / `flutter run` / `flutter build`, regardless of
what the project actually contains.

Two concrete problems from this:
- A Dart-only package (e.g. `dart create -t web`) that uses `web/` as a
real source directory gets it silently excluded from analysis the first
time any `flutter` command touches the package (this happens in mixed
Flutter/Dart monorepos and Dart workspaces).
- A Flutter app created with `flutter create --platforms=android,ios`
still gets exclusions for `web/`, `windows/`, `macos/`, and `linux/`,
which it doesn't have, and `ProjectMigrator` has no opt-out — every
command restores the full list.

Fix:
- `AnalysisOptionsMigration.migrate()` now skips entirely when the
package has no `flutter` dependency (i.e. it isn't a Flutter project at
all — the discriminator suggested in the issue).
- The exclude list is now built conditionally from
`project.<platform>.existsSync()` for each platform, so only directories
the project actually has as platform scaffolds are excluded. `build/**`
stays unconditional.
- `templates/app/analysis_options.yaml.tmpl` (used by `flutter create`)
gets the same per-platform conditionals via the existing mustache
context (`{{#android}}`, `{{#ios}}`, etc.), so newly created projects
don't get the fixed list either.

Fixes flutter#191131

## Pre-launch Checklist

- [ ] I read the [Contributor Guide] and followed the process outlined
there for submitting PRs.
- [ ] I read the [AI contribution guidelines] and understand my
responsibilities, or I am not using AI tools.
- [ ] I read the [Tree Hygiene] wiki page, which explains my
responsibilities.
- [ ] I read and followed the [Flutter Style Guide], including [Features
we expect every widget to implement].
- [ ] I signed the [CLA].
- [x] I listed at least one issue that this PR fixes in the description
above.
- [ ] I updated/added relevant documentation (doc comments with `///`).
- [x] I added new tests to check the change I am making, or this PR is
[test-exempt].
- [ ] I followed the [breaking change policy] and added [Data Driven
Fixes] where supported.
- [x] All existing and new tests are passing.

<!-- Links -->
[Contributor Guide]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#overview
[AI contribution guidelines]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#ai-contribution-guidelines
[Tree Hygiene]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md
[test-exempt]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#tests
[Flutter Style Guide]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Style-guide-for-Flutter-repo.md
[Features we expect every widget to implement]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Style-guide-for-Flutter-repo.md#features-we-expect-every-widget-to-implement
[CLA]: https://cla.developers.google.com/
[breaking change policy]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#handling-breaking-changes
[Data Driven Fixes]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Data-driven-Fixes.md
@flutteractionsbot flutteractionsbot added the cp: review Cherry-picks in the review queue label Aug 22, 2026
@flutteractionsbot

Copy link
Copy Markdown
Contributor Author

@AlexV525 please fill out the PR description above, afterwards the release team will review this request.

@flutter-dashboard flutter-dashboard Bot added the CICD Run CI/CD label Aug 22, 2026
@flutter-dashboard

Copy link
Copy Markdown

This pull request was opened from and to a release candidate branch. This should only be done as part of the official Flutter release process. If you are attempting to make a regular contribution to the Flutter project, please close this PR and follow the instructions at Tree Hygiene for detailed instructions on contributing to Flutter.

Reviewers: Use caution before merging pull requests to release branches. Ensure the proper procedure has been followed.

@github-actions github-actions Bot added the tool Affects the "flutter" command-line tool. See also t: labels. label Aug 22, 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 options migration and template generation to only exclude platform-specific directories (such as android/, ios/, etc.) if they actually exist in the project. It also skips the migration entirely for pure Dart packages that do not depend on Flutter. Unit and integration tests have been added and updated to verify these behaviors, including refactoring the test context to use a real FlutterProject view of an in-memory directory instead of a fake. There are no review comments, and I have no feedback to provide.

@AlexV525 AlexV525 changed the title [CP-stable]Only exclude platform directories that actually exist in analysis_options.yaml [stable] Only exclude platform directories that actually exist in analysis_options.yaml Aug 22, 2026
@AlexV525
AlexV525 requested a review from bkonyi August 22, 2026 05:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CICD Run CI/CD cp: review Cherry-picks in the review queue tool Affects the "flutter" command-line tool. See also t: labels.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants