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

New RuboCop autocorrect #955

Merged
merged 1 commit into from Jul 9, 2020
Merged

New RuboCop autocorrect #955

merged 1 commit into from Jul 9, 2020

Commits on Jul 9, 2020

  1. Use the new Autocorrection API

    The autocorrection API was changed in Rubocop v0.87.0 (pull request rubocop/rubocop#7868).
    
    Here, I change the superclass of `RuboCop::Cop::RSpec::Cop` from
    `::RuboCop::Cop::Cop` to `::RuboCop::Cop::Base`.
    
    This has a few consequences:
    
    - Our `#message` methods get called with a different argument than
      before. It *can* be customized by defining a `#callback_argument`
      method, but I think it is clearer to avoid callbacks altogether.
    - Our `#autocorrect` methods don't get called anymore. Instead, we
      extend `Autocorrector`, and the `corrector` is being yielded when
      calling `#add_offense`, so the code is mostly moved in there. For some
      cases, this means that some code can be removed, which is nice. For
      some cases, it means that the methods get too long, or the code
      complexity gets too high, and in those cases I chose to just call out
      to an `#autocorrect` method anyway, but of course passing the
      `corrector` and any usable local variables along.
    
    This also means we bump the dependency of RuboCop quite a bit, from
    '>= 0.68.1' to '>= 0.87.0'.
    bquorning committed Jul 9, 2020
    Copy the full SHA
    ac953d8 View commit details
    Browse the repository at this point in the history