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

Initial spike on Autocorrect #985

Open
wants to merge 12 commits into
base: master
Choose a base branch
from

Commits on Jul 27, 2022

  1. Add autocorrect to default suggest pipeline

    At this point the pipeline for the default "suggest" task has been
    modified to include an Autocorrect step. That's all hooked up, and a
    callback for `autocorrect/1` has been added to the `Credo.Check`
    behaviour and the default implementation. This can be implemented for
    each check individually, and it's a noop for now.
    devonremote committed Jul 27, 2022
    Configuration menu
    Copy the full SHA
    140488b View commit details
    Browse the repository at this point in the history
  2. Add run autocorrect task & tests

    At this point the task in the execution pipeline for running the
    autocorrect is implemented & tested. It's naive, but it should work in
    basic cases!
    devonremote committed Jul 27, 2022
    Configuration menu
    Copy the full SHA
    0ef3eb7 View commit details
    Browse the repository at this point in the history
  3. Autocorrect implemented & working for a single check

    At this point we have autocorrect functionality implemented & working
    for the TrailingBlankLine check. I've verified this with manual testing.
    The UX still has a ton of work to do, but for now the bulk of the work
    is actually working.
    devonremote committed Jul 27, 2022
    Configuration menu
    Copy the full SHA
    7a0dada View commit details
    Browse the repository at this point in the history
  4. Now able to pass --autocorrect flag to mix credo

    We can now pass an `--autocorrect` flag to the default `suggest` command
    when running `mix credo` and it works!
    devonremote committed Jul 27, 2022
    Configuration menu
    Copy the full SHA
    93cba5d View commit details
    Browse the repository at this point in the history
  5. Remove autocorrected issues before displaying results

    Now when we autocorrect an issue, we remove that issue from the stored
    list of issues so it isn't shown to the user (since technically it's no
    longer an issue since it was autocorrected).
    
    One other thing we might do is to change the formatter to display when
    an issue was there and to indicate that it was autocorrected, also
    making sure the exit code is 0 for any autocorrected issues, but for now
    this seemed like a reasonable path forward and much simpler than this
    option.
    devonremote committed Jul 27, 2022
    Configuration menu
    Copy the full SHA
    a0042a5 View commit details
    Browse the repository at this point in the history
  6. Implement most basic version of alias ordering autocorrect

    At this point it will autocorrect the most basic version of alias
    ordering, but it doesn't yet handle multi-aliases or handle groupings of
    aliases. That will come in a later commit.
    devonremote committed Jul 27, 2022
    Configuration menu
    Copy the full SHA
    b98842f View commit details
    Browse the repository at this point in the history
  7. More alias ordering autocorrect behavior implemented

    More basics of the autocorrect behavior for the alias ordering check
    have been implemented, and now we just need to handle blocks of aliases
    with whitespace between them.
    devonremote committed Jul 27, 2022
    Configuration menu
    Copy the full SHA
    f5f1343 View commit details
    Browse the repository at this point in the history
  8. "Finish" implementing autocorrect for ordering aliases

    We've now handled pretty much all the use cases for ordering aliases
    automatically. There is some formatter whackiness that will need to be
    figured out, but beyond that this is a good example of how an
    autocorrect callback might be implemented for a more involved check than
    the first one.
    devonremote committed Jul 27, 2022
    Configuration menu
    Copy the full SHA
    0d84490 View commit details
    Browse the repository at this point in the history

Commits on Jul 28, 2022

  1. Add autocorrect callback for line endings consistency check

    This is the first implementation of an autocorrect callback for a
    consistency check. I don't _love_ how we're doing it right now since
    we're not actually storing the state of what the "correct" behavior is
    that should be changed to, so instead we're just using the issue message
    to give us information about what the autocorrect behavior should be.
    It's not great, but it works!
    devonremote committed Jul 28, 2022
    Configuration menu
    Copy the full SHA
    fb4be0e View commit details
    Browse the repository at this point in the history
  2. Add autocorrect for unless with else check

    This autocorrects an unless with else check so that we're changing it to
    an `if` statement.
    devonremote committed Jul 28, 2022
    Configuration menu
    Copy the full SHA
    ab77dcd View commit details
    Browse the repository at this point in the history
  3. Add basics for unused string operation autocorrect

    This adds the first bits of an implementation for how we might want to
    autocorrect an unused String operation. Unfortunately because there's
    nothing in the AST that represents **nothing**, anything we replace that
    unused String operation with in the AST will be compiled into something
    - even if just the literal atom `nil`. That would probably be better
    than unused String operations since those would just be noops in the
    runtime, but they would be potentially confusing in the code.
    
    If we want to actually do this there's probably a _lot_ more that would
    need to be done for this check, but what we have offers a glimpse into
    how this kind of check could be autocorrected as a proof of concept.
    devonremote committed Jul 28, 2022
    Configuration menu
    Copy the full SHA
    acd96bb View commit details
    Browse the repository at this point in the history

Commits on Jul 29, 2022

  1. Configuration menu
    Copy the full SHA
    4bb4095 View commit details
    Browse the repository at this point in the history