dart-lang / sdk

The Dart SDK, including the VM, JS and Wasm compilers, analysis, core libraries, and more.
https://dart.dev
BSD 3-Clause "New" or "Revised" License
10.23k stars 1.57k forks source link

Discussion about automated fixes #35550

Open bwilkerson opened 5 years ago

bwilkerson commented 5 years ago

@munificent @danrubel

I think it's great that we added some updating support to dartfmt to help our users. However, we have now started working on dartfix as a tool for automating code changes. I think it's worth having a discussion about what the best path forward is from our users perspective.

Should we have a single tool that automates code changes? If so, should that be dartfmt or dartfix, or should we have two tools that apply fixes, with dartfmt performing syntactic fixes while dartfix performs semantic fixes?

Personally, I think all of the fixes should be implemented in one tool, but I'm interested to know other people's thoughts.

(This might impact https://github.com/dart-lang/dart_style/issues/753 and https://github.com/dart-lang/linter/issues/1338.)

munificent commented 5 years ago

I look at dartfmt and dartfix as being mostly complementary tools with also probably some overlap. As long as we don't waste a ton of time re-implementing the same fixes twice, I don't think the overlap is hugely problematic. I care more that users get shipped the fix at all than I care which tools ships it.

I also think there are many non-overlapping cases for the tools:

Pragmatically, people are using and like the fixes dartfmt supports. It's a well-known tool that users trust and know how to run. I don't think it will make users happy to remove these features now in the name of abstract ideals of orthogonality, so we're stuck with them.

bwilkerson commented 5 years ago

I understand your arguments, but I still think it could be confusing to new users who have no opinion where this feature should live. Having a single feature split between two tools just seems wrong to me.

Perhaps a better time to tackle this would be if we move to a single command with sub-commands, such as dart format and dart fix.

@mit-mit @kevmoo Curious whether you have opinions.

munificent commented 5 years ago

Will dartfix support fixes that can be applied to code containing static errors? If so, and the performance is good enough, I'd be fine with removing the fixes from dartfmt and putting them only in dartfix if it seems like our users are OK with it.

bwilkerson commented 5 years ago

Yes. At least one of the fixes it already supports depends on looking for a semantic error in order to figure out which code to fix.

kwalrath commented 5 years ago

It'll be easier for me to explain if there's only one tool that makes these kinds of fixes.