ruby / gem_rbs_collection

A collection of RBS for gems.
MIT License
255 stars 106 forks source link

Introduce rubocop-on-rbs #608

Open ksss opened 3 months ago

ksss commented 3 months ago

Introduce rubocop-on-rbs Implements of #601

As an introduction, we automated the pointing out by rubocop-on-rbs to activesupport.

.rubocop.yml

Root

I have included common settings in the project root .rubocop.yml, but disabled all Cop.

Each gems

I have enabled RBS/Layout and RBS/Lint only in activesupport. With other gems, rubocop detection does not work depending on the route configuration. This means that the owner of the gem can optionally set .rubocop.yml to enable the check.

CI

By running RuboCop in CI, automatic feedback can be displayed on PRs. This frees reviewers from pointing out trivial issues and allows them to focus on essential reviews.

Operation check

You can see that RBS/Layout is enabled and RBS/Style is not.

image

When Updating rubocop-on-rbs

When New Cops Are Added via gem Update

New Cops are disabled by default. There is no burden from the gem update. If you want to enable new Cops, you need to do so for each gem.

When the Behavior of Existing Cops Changes

You need to make sure that RuboCop passes for all gems (this is assumed to be a rare case).

When Adding a New gem

Use init_new_gem to add a .rubocop.yml file. If unnecessary, simply delete this file. This file enables most Cops by default.

github-actions[bot] commented 3 months ago

@ksss Thanks for your contribution!

Please follow the instructions below for each change. See also: https://github.com/ruby/gem_rbs_collection/blob/main/docs/CONTRIBUTING.md

Available commands

You can use the following commands by commenting on this PR.


activesupport

You changed RBS files for an existing gem. You can merge this PR yourself because you are a reviewer of this gem. Just comment /merge to merge this PR.

You can also request a review from other reviewers if you want.


You changed non-gem files.

@pocke, please review and approve the changes.

pocke commented 3 months ago

Thanks for your pull request.

Decreasing development speed is my main concern when introducing RuboCop. But probably this opt-in approach can reduce the negative impact because RuboCop is enabled only for maintainer who want to use it.

By the way, we can probably update the init_new_gem script to create a boilerplate of .rubocop.yml.

ksss commented 3 months ago

@pocke Good idea. I updated init_new_gem. And to facilitate the update of rubocop-on-rbs, I have rewritten the settings on a per-cop basis.

ksss commented 3 months ago

@pocke I also thought about the operation of updating rubocop-on-rbs. Do you have any concerns?