Skip to content

Fix lints on format/save and Fix-all #3445

Closed

Description

@rrousselGit

Is your feature request related to a problem? Please describe.
Numerous lints come with an auto-fix option, but we have to apply the fixes almost one by one, which is tedious.

Describe the solution you'd like
Since VS code already keeps tracks of the list of issues and offers to fix them, VS code could expose a command for "apply all fixes".

Similarly, we could have an option to, right before executing dartfmt, apply fixes for the file.

Describe alternatives you've considered
N/A

Additional context
N/A

Activity

  1. added
    is enhancementAn enhancement or improvement that should be listed in release notes but is not a bug fix.
    on Jul 1, 2021
  2. added this to the v3.25.0 milestone on Jul 1, 2021
  3. added
    in editorRelates to code editing or language features
    in lsp/analysis serverSomething to be fixed in the Dart analysis server
    on Jul 1, 2021
  4. DanTup commented on Jul 1, 2021

    @DanTup
    Member

    I think this would make sense implemented as a Source CodeAction (source.fixAll), which can be added to editor.codeActionsOnSave:

    https://code.visualstudio.com/updates/v1_32#_fix-all-source-actions

    It should follow the guides given by VS Code:

    Fix all actions automatically fix errors that have a clear fix that do not require user input. They should not suppress errors or perform unsafe fixes such as generating new types or classes.

    It should be implemented in the server so it's a single request that builds all fixes, and not enumerated on the client as applying fixes for one diagnostic could interfere with others (for example changing offsets, or invalidating some other fixes), and repeated round trips to the server could be slow.

    I think the server already has all the parts necessary for this (between dart fix and the (experimental) edit.bulkFixes call in the original protocol), but I'm not certain if they're stable enough to expose here yet.

  5. DanTup commented on Jul 7, 2021

    @DanTup
    Member

    dart-lang/sdk@85d455f adds an implementation for "source.fixAll" which can be run from the command palette (Fix All) or added to editor.codeActionsOnSave.

    It only fixes the same things that dart fix/flutter fix will fix (which is not the whole set of fixes available in the lightbulb menu, but those that are deemed safe to fix in an automated way (this work might not be complete, so it may still expand over time)).

  6. ViniciusSossela commented on Aug 3, 2021

    @ViniciusSossela

    @DanTup @rrousselGit I am trying to launch the Fix All command, but it doesn't show on the command palette. Am I missing something?

    Screen Shot 2021-08-03 at 10 11 21

    Screen Shot 2021-08-03 at 10 13 45

    Flutter 2.2.3 • channel stable • https://github.com/flutter/flutter.git
    Framework • revision f4abaa0735 (5 weeks ago) • 2021-07-01 12:46:11 -0700
    Engine • revision 241c87ad80
    Tools • Dart 2.13.4
    
    
  7. DanTup commented on Aug 3, 2021

    @DanTup
    Member

    See my reply at #3469 (comment), thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    in editorRelates to code editing or language featuresin lsp/analysis serverSomething to be fixed in the Dart analysis serveris enhancementAn enhancement or improvement that should be listed in release notes but is not a bug fix.

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions