Skip to content

Updated analysis_options line width from flutter/flutter#11692

Merged
auto-submit[bot] merged 24 commits into
flutter:mainfrom
justinmc:analysis_options_update
Jun 3, 2026
Merged

Updated analysis_options line width from flutter/flutter#11692
auto-submit[bot] merged 24 commits into
flutter:mainfrom
justinmc:analysis_options_update

Conversation

@justinmc
Copy link
Copy Markdown
Contributor

@justinmc justinmc commented May 11, 2026

It seems like we're supposed to keep analysis_options.dart in sync with the one in flutter/flutter, but we haven't done it since 2023. This PR updates it. The most disruptive change appears to be the increased page width.

I'm inspired to update this after working on #11669, which imports flutter/flutter code that is formatted according to the latest rules. Better to update the rules than to format the new code back to the old rules.

Update: This only updates the line width. Other changes will follow.

@justinmc justinmc requested a review from stuartmorgan-g May 11, 2026 20:31
@flutter-dashboard flutter-dashboard Bot added the CICD Run CI/CD label May 11, 2026
Copy link
Copy Markdown

@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 updates the analysis_options.yaml file to synchronize with the Flutter repository, adding a formatter configuration with a 100-character page width and enabling several new linter rules such as annotate_redeclares and strict_top_level_inference. Review feedback indicates that the # not yet tested comment on the enabled omit_obvious_local_variable_types rule is misleading and should be removed. Additionally, the reviewer noted that several documentation links were broken by the introduction of relative paths and should be restored to absolute URLs.

Comment thread analysis_options.yaml Outdated
# - omit_local_variable_types # conflicts with specify_nonobvious_local_variable_types
- omit_obvious_local_variable_types
# - omit_local_variable_types # superset of omit_obvious_local_variable_types
- omit_obvious_local_variable_types # not yet tested
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

medium

The lint omit_obvious_local_variable_types is enabled, but it is marked with a # not yet tested comment. In this file, this specific comment is consistently used for lints that are disabled (commented out) while awaiting verification. Since this lint was already active in the previous version of the configuration and remains enabled here, the comment is misleading and should be removed.

    - omit_obvious_local_variable_types

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Let's fix this.

Comment thread analysis_options.yaml Outdated
- prefer_contains
# - prefer_double_quotes # opposite of prefer_single_quotes
# - prefer_expression_function_bodies # conflicts with https://github.com/flutter/flutter/blob/master/docs/contributing/Style-guide-for-Flutter-repo.md#consider-using--for-short-functions-and-methods
# - prefer_expression_function_bodies # conflicts with ./docs/contributing/Style-guide-for-Flutter-repo.md#consider-using--for-short-functions-and-methods
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

medium

The relative path ./docs/contributing/Style-guide-for-Flutter-repo.md is broken in the context of the flutter/packages repository, as the referenced documentation resides in the flutter/flutter repository. Please restore the absolute URL to ensure the link remains functional for contributors.

    # - prefer_expression_function_bodies # conflicts with https://github.com/flutter/flutter/blob/master/docs/contributing/Style-guide-for-Flutter-repo.md#consider-using--for-short-functions-and-methods

Comment thread analysis_options.yaml Outdated
- prefer_initializing_formals
- prefer_inlined_adds
# - prefer_int_literals # conflicts with https://github.com/flutter/flutter/blob/master/docs/contributing/Style-guide-for-Flutter-repo.md#use-double-literals-for-double-constants
# - prefer_int_literals # conflicts with ./docs/contributing/Style-guide-for-Flutter-repo.md#use-double-literals-for-double-constants
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

medium

The relative path ./docs/contributing/Style-guide-for-Flutter-repo.md is broken in this repository. This link should be restored to its absolute URL to point to the correct documentation in the flutter/flutter repository.

    # - prefer_int_literals # conflicts with https://github.com/flutter/flutter/blob/master/docs/contributing/Style-guide-for-Flutter-repo.md#use-double-literals-for-double-constants

@github-actions github-actions Bot removed the CICD Run CI/CD label May 11, 2026
@justinmc justinmc added the CICD Run CI/CD label May 11, 2026
Comment thread analysis_options.yaml Outdated
# - prefer_double_quotes # opposite of prefer_single_quotes
# - prefer_expression_function_bodies # conflicts with ./docs/contributing/Style-guide-for-Flutter-repo.md#consider-using--for-short-functions-and-methods
- prefer_final_fields
# - prefer_expression_function_bodies # conflicts with https://github.com/flutter/flutter/blob/master/docs/contributing/Style-guide-for-Flutter-repo.md#consider-using--for-short-functions-and-methods - prefer_final_fields
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Why was prefer_final_fields pulled into this line and thus removed?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Typo, thanks for catching that!

Comment thread analysis_options.yaml Outdated
# - omit_local_variable_types # conflicts with specify_nonobvious_local_variable_types
- omit_obvious_local_variable_types
# - omit_local_variable_types # superset of omit_obvious_local_variable_types
- omit_obvious_local_variable_types # not yet tested
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Let's fix this.

Comment thread analysis_options.yaml Outdated
- type_annotate_public_apis
- type_init_formals
- type_literal_in_constant_pattern
# - unawaited_futures # too many false positives, especially with the way AnimationController works
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

This is on, it's just in the wrong place. It's two lines down.

@stuartmorgan-g
Copy link
Copy Markdown
Collaborator

I'm not sure what's going on here, but most of the tests never ran. If you are changing the line length, you're going to have to reformat the entire repo in this PR otherwise CI will (when it actually runs) fail.

@github-actions github-actions Bot removed the CICD Run CI/CD label May 12, 2026
@justinmc justinmc changed the title Updated analysis_options from flutter/flutter Updated analysis_options line width from flutter/flutter Jun 2, 2026
assert(library is Null); // ignore: prefer_void_to_null, type_check_with_null, https://github.com/dart-lang/sdk/issues/47017#issuecomment-907562014
assert(
library is Null,
); // ignore: prefer_void_to_null, type_check_with_null, https://github.com/dart-lang/sdk/issues/47017#issuecomment-907562014
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

The reformat broke this // ignore; you'll need to move it manually.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Thanks!

@github-actions github-actions Bot removed the CICD Run CI/CD label Jun 2, 2026
@justinmc justinmc added the CICD Run CI/CD label Jun 2, 2026
@Piinks
Copy link
Copy Markdown
Contributor

Piinks commented Jun 2, 2026

Looks like go_router_builder/example needs formatting here.

@justinmc
Copy link
Copy Markdown
Contributor Author

justinmc commented Jun 2, 2026

It looks like CI is not picking up the line length change that I added to the root analysis_options.yaml for some reason. For example

-    GoRouteData.$route(path: 'int-route/:requiredIntField', factory: $IntExtensionRoute._fromState),
-    GoRouteData.$route(path: 'num-route/:requiredNumField', factory: $NumExtensionRoute._fromState),
+    GoRouteData.$route(
+      path: 'int-route/:requiredIntField',
+      factory: $IntExtensionRoute._fromState,
+    ),
+    GoRouteData.$route(
+      path: 'num-route/:requiredNumField',
+      factory: $NumExtensionRoute._fromState,
+    ),

It's telling me to go back to a shorter line length. Maybe it's because those are generated files and they should be ignored by the formatter?

@github-actions github-actions Bot removed the CICD Run CI/CD label Jun 2, 2026
@justinmc justinmc added the CICD Run CI/CD label Jun 2, 2026
justinmc added 3 commits June 2, 2026 16:16
This reverts commit c420322.

It looks like the root analysis_options.yaml already excludes these
generated files!
This reverts commit 8cc0a71.
@github-actions github-actions Bot removed the CICD Run CI/CD label Jun 2, 2026
@stuartmorgan-g stuartmorgan-g added the CICD Run CI/CD label Jun 3, 2026
@github-actions github-actions Bot removed the CICD Run CI/CD label Jun 3, 2026
@stuartmorgan-g
Copy link
Copy Markdown
Collaborator

Note: Normally we would publish updates for README changes (which update-excerpts triggered), but we've skipped that for mass reformats since the code is correct either way, so there's no user-driven need to publish the changes in a timely manner.

@stuartmorgan-g
Copy link
Copy Markdown
Collaborator

stuartmorgan-g commented Jun 3, 2026

rfw has some files that had opted out of autoformat enforcement. I wasn't going to worry about that since I think we should revisit whether we support that at all now that flutter/flutter autoformats (the context here was that Hixie didn't want the formatter enforced on rfw back when the framework still didn't autoformat), but it turns out that the package has some custom coverage checking in its package-specific tests, and it has special logic based on comment annotations that the autoformatter moves. So I'm reverting the autoformat changes in the opted-out files, and I'll file an issue (edit: flutter/flutter#187508) to eventually consider removing the opt-out support (and then changing the coverage calculation logic).

@stuartmorgan-g
Copy link
Copy Markdown
Collaborator

go_router_builder is a conflict between what the autoformatter wants, and what the generator generates; there's a unit test that runs the generation and makes sure nothing changed, so currently either that test fails or the format check files. I'm sure we hit this with the last big reformat, and I'm trying to figure out how we handled it then.

@justinmc
Copy link
Copy Markdown
Contributor Author

justinmc commented Jun 3, 2026

Thank you for the help here! I'll plan to wait for what you find out for go_router_builder. If you want me to apply the diffs from the failure or anything else in the meantime let me know.

@stuartmorgan-g
Copy link
Copy Markdown
Collaborator

It turns out this case was different from the previous case, but chunhtai pointed me to the actual problem and solution. For posterity (it's in comments in the PR diffs, but a comment here may be more discoverable for a future person searching old PRs like I was): the issue this time was that go_router_builder is using the dart_style package, and it uses code-based configuration rather than reading local analysis options. So go_router_builder makes code that uses the default of 80 columns, while we are expecting files in the repo to be formatted with 100 now.

So what was happening was:

  • The repo format check would fail if go_router_builder/example used 80-column format
  • expectBuildClean in ensure_build_test.dart would fail if go_router_builder/example used 100-column format, because all the checked-in, go_router_builder-generated files are the goldens for that test.

The simple solution chunhtai pointed out was that we can give go_router_builder/example custom analysis settings that set just that sub-project to 80 columns.

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants