Updated analysis_options line width from flutter/flutter#11692
Conversation
There was a problem hiding this comment.
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.
| # - 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 |
There was a problem hiding this comment.
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| - 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 |
There was a problem hiding this comment.
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| - 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 |
There was a problem hiding this comment.
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| # - 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 |
There was a problem hiding this comment.
Why was prefer_final_fields pulled into this line and thus removed?
There was a problem hiding this comment.
Typo, thanks for catching that!
| # - 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 |
| - type_annotate_public_apis | ||
| - type_init_formals | ||
| - type_literal_in_constant_pattern | ||
| # - unawaited_futures # too many false positives, especially with the way AnimationController works |
There was a problem hiding this comment.
This is on, it's just in the wrong place. It's two lines down.
|
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. |
| 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 |
There was a problem hiding this comment.
The reformat broke this // ignore; you'll need to move it manually.
|
Looks like go_router_builder/example needs formatting here. |
|
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 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? |
|
Note: Normally we would publish updates for README changes (which |
|
|
|
|
|
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. |
|
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 So what was happening was:
The simple solution chunhtai pointed out was that we can give |
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.