Skip to content

Updated analysis_options line width from flutter/flutter#11692

Open
justinmc wants to merge 16 commits into
flutter:mainfrom
justinmc:analysis_options_update
Open

Updated analysis_options line width from flutter/flutter#11692
justinmc wants to merge 16 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
@stuartmorgan-g
Copy link
Copy Markdown
Collaborator

@justinmc Do you want me to try to get this updated, through tests, and landed sometime morning my time when there's not much tree activity, to minimize the chance of conflicts?

@justinmc
Copy link
Copy Markdown
Contributor Author

justinmc commented Jun 1, 2026

@stuartmorgan-g Yes please if you have time! I keep forgetting about this.

@justinmc
Copy link
Copy Markdown
Contributor Author

justinmc commented Jun 2, 2026

Actually I'm going to go ahead and attempt this right now. If I fail I'll reach out for help!

justinmc added 3 commits June 2, 2026 09:52
This reverts commit 4210b40.

Doing this per @stuartmorgan's instructions in order to try to unblock
this from landing and fix merge conflicts.
@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
@stuartmorgan-g
Copy link
Copy Markdown
Collaborator

I was actually just looking at this; a locally analysis run is showing a bunch of failures.

I think we should split this into two PRs: one to pull in the new options other than line width, fixing violations, and one that just does the reformat.

@stuartmorgan-g
Copy link
Copy Markdown
Collaborator

I'll work on analysis changes in a new PR, and you can downscope this to just the autoformat so we can try to get that landed this morning before anything else comes in.

@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 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
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