Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

default quick fixes for omit_obvious_local_variable_types #56272

Open
devoncarew opened this issue Jul 17, 2024 · 4 comments
Open

default quick fixes for omit_obvious_local_variable_types #56272

devoncarew opened this issue Jul 17, 2024 · 4 comments
Labels
analyzer-quick-fix area-analyzer Use area-analyzer for Dart analyzer issues, including the analysis server and code completion. P2 A bug or feature request we're likely to work on type-enhancement A request for a change that isn't a bug

Comments

@devoncarew
Copy link
Member

When trying to quick fix analysis issues from omit_obvious_local_variable_types, I see different defaults that the quick fixes for omit_local_variable_types. omit_obvious_local_variable_types will default to adding an ignore for an issue; omit_local_variable_types will default to replacing the type declaration with var.

omit_local_variable_types (preferred):

Screenshot 2024-07-17 at 11 34 48 AM

omit_obvious_local_variable_types (less desired):

Screenshot 2024-07-17 at 11 34 19 AM

cc @eernstg

(discussion issue at #58773)

@devoncarew devoncarew added the area-analyzer Use area-analyzer for Dart analyzer issues, including the analysis server and code completion. label Jul 17, 2024
@bwilkerson
Copy link
Member

The items under "More Actions..." are probably assists, rather than fixes. Server will not produce an assist if it's already been suggested as a fix, so the placement of "Replace type annotation with 'var'" (and the absence of the "everywhere in file" variant) is a result of the fix not being associated with the diagnostic.

The presence of "Remove type annotation" seems like a bug. It's doing exactly the same as "Replace type annotation with 'var'" and there's no value in having both appear.

@devoncarew
Copy link
Member Author

... is a result of the fix not being associated with the diagnostic

Thanks Brian! That explanation seems to match the behavior I'm seeing.

@srawlins srawlins added analyzer-quick-fix P2 A bug or feature request we're likely to work on type-enhancement A request for a change that isn't a bug labels Jul 17, 2024
@eernstg
Copy link
Member

eernstg commented Jul 18, 2024

Surely, omit_obvious_local_variable_types should give rise to the same quick fixes and assists as omit_local_variable_types — they are flagging any given location for exactly the same reasons, the only difference is that omit_local_variable_types will flag a larger number of locations than omit_obvious_local_variable_types.

Created https://dart-review.googlesource.com/c/sdk/+/376320 for this.

@FMorschel
Copy link
Contributor

@eernstg, the CL has been merged. Can this be closed?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
analyzer-quick-fix area-analyzer Use area-analyzer for Dart analyzer issues, including the analysis server and code completion. P2 A bug or feature request we're likely to work on type-enhancement A request for a change that isn't a bug
Projects
None yet
Development

No branches or pull requests

5 participants