-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
Do not include TODO comments in generated code #49331
Comments
Some projects have rules and checks that a TODO must have a particular form (e.g. include an author or issue link), and the default TODO doesn't conform to them, and can't conform to all possible formats. I agree it would be nice to not include the throw on methods that return void (or Future<void>). It sounds like the ideal thing would be to make it configurable as to whether TODOs are included or not in the suggestions. |
It was noted at flutter/devtools#4488 (comment) that when overriding, the TODO appears above the call to This issue made me wonder if it's worth just swapping them around or if they may be removed (or whether there should be preferences for TODOs, The analysis server doesn't currently have a way to express preferences (although it sometimes infers them from lints), but maybe this is something that would fit in there if it did get one. |
would it be possible to autocomplete with snippets that have tabstops for traversal instead of straight TODOs? That way the user could tab through to important parts and fill them in quickly. We could have the throw be a placeholder at the tabstop so the user could leave it if they want to as well. |
I am, of course, in favor of just removing them, since I always have to remove them manually each time I insert a snippet, which is a bore. |
I don't disagree that having TODO comments in generated code is sometimes inconvenient, but the reason we originally decided to add them is for the case where you write a class that implements an interface and you need to provide concrete implementations of a large number of methods. We have a quick fix that will add stubs for all of them, and we thought that adding a TODO in every stub would help users keep track of which methods they hadn't yet gotten to. It's possible that that use case is too rare, or that the TODOs aren't as helpful in that case as we'd expected, but that's why it works the way it does. I do, however, think that it's important to consider the bulk addition of stubs as a use case when making a decision. |
I'm just one data point, but here is my experience of the feature: When I use this feature, I most often use it in these cases:
Of all of these, I agree that the third case is the most likely to want a TODO in it, but even then each one of the added methods has a In all three of these cases, the first thing I do is to remove all of the TODOs. For me (maybe not for everyone), they just feel like they're getting in the way. The IDE highlights them as analyzer warnings because they're not the right format for our project (and even if they were, it would highlight them as TODOs), and that makes it hard to read the code, so I just want them out of there so I have "space to work". So every time I do use the feature, I spend a while cleaning up after it before I can get down to actually implementing. It's still useful enough to use, but the TODOs definitely add friction. If it's not easy to make it configurable, maybe this would be a good case for UXR to ask a few users what they think so we can make a data-based decision? |
We could certainly make is configurable, but I personally think that configuration options should be a last resort. I'd much prefer it to just work well for everyone.
I agree that we don't need two markers that perform the same purpose, and I'd much rather get rid of the comment. If we always have a |
I think for a single insertion we could set the TODO (or
Assuming we're agreed we should drop the |
I don't know. One of the goals we have is that our fixes should not produce invalid code when it's reasonable not to. That's why we decided to use a But for overriding methods, a There's some value in adding a I guess my inclination at this point would be to not add |
Thanks - that all makes sense to me.
I presume you mean |
Yes.
The question is: when does server generate an override? I can think of two cases, though there are probably more:
In neither of these cases is the override unnecessary, it's just incomplete. Adding a |
We have that lint enabled, and I would be fine with either, with a slight bias towards not adding a throw just because it means I don't have to delete anything in order to start implementing, even though it adds a lint warning. And in projects where that lint isn't enabled, there's no reason to add the throw, and it'll make your logic simpler anyhow. |
Is there a reason that the class is correctly highlighted as "overrides missing", but when I tell my IDE I want to "override methods..." (Ctrl + O in IntelliJ), the missing ones aren't available? EDIT: asking because IntelliJ's internal override would let me create the method stub without the annoying TODO comments I didn't ask for. EDIT: found the answer, note my addition below that reply. |
Original issue: flutter/flutter-intellij#6239
The request is to stop generating
TODO
comments when generating code for overridden methods. It's just more stuff to delete, and seems redundant given thethrow
statement.The text was updated successfully, but these errors were encountered: