Detect RuboCop as the formatter when it is only a transitive depenency #2126
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Motivation
Closes #1198
Implementation
I've followed what is outlined in #1198 (comment). GlobalState now has the workspace uri so the implementation is relativly straightforward. I'm slightly deviating by also checking that rubocop is a transitive dependency, seems like a good thing to do.
I've moved file checking into its own method. This is purely for tests as mocha doesn't make it possible to stub a method with only a specific set of arguments.
File.stubs(:exist?).with("foo")
disallows all other invocations of that method.Automated Tests
Added some for the combinations.
Manual Tests
That's a bit more complicated. I'm not aware of a public gem that provides a rubocop config that also doesn't start with
rubocop
. I created a local shim gem that just contains arubocop.yml
/gemspec and tested out the various scenarios.