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

No fix-all quick-fix for "Remove the !" #45769

Closed
DanTup opened this issue Apr 20, 2021 · 3 comments
Closed

No fix-all quick-fix for "Remove the !" #45769

DanTup opened this issue Apr 20, 2021 · 3 comments
Assignees
Labels
analyzer-bulk-fix area-analyzer Use area-analyzer for Dart analyzer issues, including the analysis server and code completion. type-enhancement A request for a change that isn't a bug

Comments

@DanTup
Copy link
Collaborator

DanTup commented Apr 20, 2021

In this (contrived) code I have multiple ! operators:

foo(String? aaa) => aaa == '' ? aaa!.length : aaa!.length;

If I update aaa to no longer be nullable, I get two reports of "The '!' will have no effect" and have to fix them individually, (though the original LSP fix-all code produced a fix-all for it).

There's an argument that you may want to review each case of this and not fix-all, but having a fix-all doesn't mean you have to use it. In the case where you've just introduced a bunch of these because you were removing null from some variables, it seems useful to be able to just do them all in one go (and with a good editor or source control, it's fairly easy to see exactly what was changed).

I don't feel strongly about this, but I thought it was worth querying.

@pq

@DanTup DanTup added the area-analyzer Use area-analyzer for Dart analyzer issues, including the analysis server and code completion. label Apr 20, 2021
@pq
Copy link
Member

pq commented Apr 20, 2021

/fyi @bwilkerson -- I think we talked about this case?

@pq pq added analyzer-bulk-fix type-enhancement A request for a change that isn't a bug labels Apr 20, 2021
@bwilkerson
Copy link
Member

Possibly, but I don't remember the details. It seems reasonable to me to allow the fix to be applied everywhere; a diagnostic will only be produced where it's required to be removed.

@pq
Copy link
Member

pq commented Apr 20, 2021

I can't remember the whole conversation either... I'll add this one. Thanks @DanTup !

@pq pq self-assigned this Apr 20, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
analyzer-bulk-fix area-analyzer Use area-analyzer for Dart analyzer issues, including the analysis server and code completion. type-enhancement A request for a change that isn't a bug
Projects
None yet
Development

No branches or pull requests

3 participants