ruby / gem_rbs_collection

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

[Proposal] Introduce rubocop-on-rbs #601

Open ksss opened 3 months ago

ksss commented 3 months ago

I propose introducing rubocop-on-rbs to perform static analysis on RBS.

I believe that by introducing this gem, we can aim to raise the quality of RBS.

RuboCop on RBS

RuboCop is one of the most popular static analysis tools for Ruby. rubocop-on-rbs is an extension of RuboCop that enables style checks for RBS files.

Scope

The scope of this issue is RBS files only.

Automatic feedback

Use github formatter of RuboCop on GitHub Action.

$ rubocop --format github

Since feedback is displayed on the code in the PR, we can quickly notice and address the issues.

スクリーンショット 2024-06-12 16 17 50

Since it is confined to GitHub Actions, it is also secure.

Static check only

Since we are only performing static analysis on RuboCop, there are no security issues as long as we trust the code of rubocop and rubocop-on-rbs.

Different settings for each gem

In RuboCop, placing a .rubocop.yml file in a subdirectory allows you to override the settings for that directory and its subdirectories.

By utilizing this mechanism, we can change the settings for each gem individually.

https://docs.rubocop.org/rubocop/configuration.html

On local checking

RuboCop is easy to run in a local environment, making it simple for us to verify fixes.

Features

rubocop-on-rbs provides documentation for each feature. Please take a look at it here.

https://github.com/ksss/rubocop-on-rbs/blob/main/docs/modules/ROOT/pages/cops.adoc

Introduction Steps

At first, I am considering applying the RBS/Layout and RBS/Lint features. Since some of the RBS/Style features can be quite opinionated, I plan to introduce them later after consulting with the community.