make mry config upgrading optional #260
Merged
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.
In investigating #251 Layout/FirstArgumentIndentation config options do not match rubocop mainline I learned we rely on the Mry gem to automagically update RuboCop configs between as RuboCop version change. On one hand this is nice because it brings outdated configs inline with the newer versions of RuboCop without manually checking and updating all the changing configs. Unfortunately Mry hasn't been updated since RuboCop version 0.78 and it's not negatively changing some config values that have been further modified since 0.78. Mry also never supported splitting cops or deleting cops.
In the case of the open issue here I think there was a combination of problems, one was with handling a split cop and the other is how it handles renamed cops that have been renamed again in more recent Rubocop versions. I added a config check to disable mry. By default it's enabled so users won't see any new, unexpected errors unless they choose to opt out of the mry config upgrading.
To disable rubocop plugin in
.codeclimate.yml
should look something like:Test Locally
.codeclimate.yml
with:I tested this by adding the Layout/FirstArgumentIndentation cop to my rubocop yaml file with an invalid style.
When running with Mry enabled I got an invalid EnforcedStyle error with the message:
This is incorrect, as Mry seems to direct the
FirstArgumentIndentation
to theFirstParameterIndention
cop. When I disable Mry and run the analyze again I get the expected SupportedStyles for the cop:Alternatives
I considered making pull requests to the Mry project rather than making this PR, but I think this is the most effective approach given how long it's been since Mry was updated. Also RuboCop just released version 1.0 so I imagine the cops will be more stable going forward and we might consider dropping Mry completely when we release new versions. If users choose to disable Mry they may need to spend some time updating older cops manually, but they'll see error messages related to those so it may end up just being tedious, rather than challenging to migrate off the Mry support.