-
Notifications
You must be signed in to change notification settings - Fork 318
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
Please don't remove unused parameters from function definitions on Save #4655
Comments
Have you enabled @bwilkerson @jacob314 we currently only exclude "remove unused imports" when running code actions on-save. It seemed like the only paint point (and we wanted to minimise differences between running manually/automatically), but perhaps I didn't realise that some of these "dead code" removal fixes were flagged to run in bulk. I wonder there should be another flag in addition to (+ @srawlins - maybe also applicable to a fix you were describing recently?) * yet... I think we'd like to apply some fixes automatically on save by default in future |
Yes, I have that enabled.
Sounds reasonable to me. |
An observation: even with |
Adding |
I wasn't thrilled when we added I've only thought about it briefly, so I'm probably missing something, but, for example, it seems to me that there are two conditions that matter when deciding whether to apply a fix from a given affordance (assuming that the affordance will attempt to apply the fix everywhere and doesn't given the user the option to explicitly select which fixes to run):
I'm fine with adding the proposed flag temporarily because I believe that there's a problem that needs to be fixed (though I'd prefer to call it |
Yep, this seems right to me (I'm interpreting "incomplete" to mean code that is still being worked on and not necessarily in an invalid state). There are some kinds of "cleanup" you might want to do only at the end (eg. just before committing).
Seems reasonable to me. I used Automatically because I thought it was a little less specific in case in future we had other ways of prompting to fix (does anyone want an annoying paperclip while they're typing? 😁) I'm curious if you have ideas for how this might eventually work though. I had thought about exposing both "groups" of these fixes via commands (eg. a "Fix All" and a "Fix All inc. dead code removal" and you could trigger either on-save), although that still requires defining these "groups" (either in the server, or by exposing some configuration). I'm not sure if that's the kind of thing you had in mind, or something else. |
Correct. Thanks for the clarification.
It's likely that users will want both affordances in the IDE, but I haven't thought much about the UX associated with them. But yes, I would consider each of those commands to be a separate affordance. |
Whatever the configuration options that are provided, I don't think unused code should ever be removed automatically. Unused code can be removed manually by quick-fix actions (Ctrl+.), sure. But not on save. |
…-on-save Fixes Dart-Code/Dart-Code#4655 Change-Id: I09269766124f7b77fde7c499c6f69a09989d1766 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/317684 Commit-Queue: Brian Wilkerson <brianwilkerson@google.com> Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
With dart-lang/sdk@6229694, removing unused parameters will only happen if you manually run the Fix All command and not when run on-save. The change ships in the SDK so will show up in a future SDK update (not a Dart-Code update). |
Thank you @DanTup! |
Describe the bug
Create this class:
Now hit save. You get:
this.param
is removed automatically, because it is (as yet) unused.This is not good default behavior. (Or maybe I accidentally enabled it in my settings, but it's not good behavior in general.)
Please complete the following information:
The text was updated successfully, but these errors were encountered: