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

Introduce rubocop-on-rbs #608

Open
wants to merge 14 commits into
base: main
Choose a base branch
from
22 changes: 22 additions & 0 deletions .github/workflows/rubocop.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
name: RuboCop

on:
push:
branches:
- main
pull_request: {}

jobs:
rubocop:
runs-on: ubuntu-latest
timeout-minutes: 30
steps:
- uses: actions/checkout@v4
- uses: ruby/setup-ruby@v1
with:
ruby-version: '3.3'
bundler-cache: true
- name: 'Install dependencies'
run: 'bundle install'
- name: 'Run RuboCop'
run: 'bundle exec rubocop --format github'
30 changes: 30 additions & 0 deletions .rubocop.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# The behavior of RuboCop can be controlled via the .rubocop.yml
# configuration file. It makes it possible to enable/disable
# certain cops (checks) and to alter their behavior if they accept
# any parameters. The file can be placed either in your home
# directory or in some project directory.
#
# RuboCop will start looking for the configuration file in the directory
# where the inspected file is and continue its way up to the root directory.
#
# See https://docs.rubocop.org/rubocop/configuration
require:
- rubocop-on-rbs

AllCops:
TargetRubyVersion: 3.3
NewCops: disable
DisabledByDefault: true
Exclude:
- "**/Steepfile"
- "**/*.rb"
- "**/vendor/**/*"

RBS:
Enabled: true
RBS/Layout:
Enabled: false
RBS/Lint:
Enabled: false
RBS/Style:
Enabled: false
Comment on lines +23 to +30
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let me confirm this configuration. Is this configuration for the RBS department necessary?
I guess we can simply remove these lines because DisabledByDefault: true is configured.

Copy link
Collaborator Author

@ksss ksss Oct 29, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can remove the RBS department at here.
But we will have to set Enabled: true for the RBS department in the .rubocop.yml under all gems.

1 change: 1 addition & 0 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,4 @@ gem "rbs"
gem "steep"
gem "typeprof"
gem "rake"
gem 'rubocop-on-rbs'
21 changes: 21 additions & 0 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ GEM
rb-inotify (~> 0.9, >= 0.9.10)
logger (1.6.1)
minitest (5.25.1)
parallel (1.26.3)
parser (3.3.5.0)
ast (~> 2.4.1)
racc
Expand All @@ -41,6 +42,24 @@ GEM
ffi (~> 1.0)
rbs (3.6.1)
logger
regexp_parser (2.9.2)
rubocop (1.67.0)
json (~> 2.3)
language_server-protocol (>= 3.17.0)
parallel (~> 1.10)
parser (>= 3.3.0.2)
rainbow (>= 2.2.2, < 4.0)
regexp_parser (>= 2.4, < 3.0)
rubocop-ast (>= 1.32.2, < 2.0)
ruby-progressbar (~> 1.7)
unicode-display_width (>= 2.4.0, < 3.0)
rubocop-ast (1.32.3)
parser (>= 3.3.1.0)
rubocop-on-rbs (1.1.0)
rbs (~> 3.5)
rubocop (~> 1.61)
zlib
ruby-progressbar (1.13.0)
securerandom (0.3.1)
steep (1.8.1)
activesupport (>= 5.1)
Expand All @@ -65,13 +84,15 @@ GEM
tzinfo (2.0.6)
concurrent-ruby (~> 1.0)
unicode-display_width (2.6.0)
zlib (3.1.1)

PLATFORMS
ruby

DEPENDENCIES
rake
rbs
rubocop-on-rbs
steep
typeprof

Expand Down
22 changes: 22 additions & 0 deletions bin/init_new_gem
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,28 @@ put base / 'manifest.yaml', <<~'YAML'
# - name: pathname
YAML

put base.parent / '.rubocop.yml', <<~'YAML'
# This configuration inherits from /.rubocop.yml.
# You can configure RBS style of this gem.
# This file is used on CI. It is configured to automatically
# make rubocop suggestions on pull requests for this gem.
# If you do not like the style enforcement, you should remove this file.
inherit_from: ../../.rubocop.yml

##
# If you want to customize the style, please consult with the gem reviewers.
# You can see the list of cops at https://github.com/ksss/rubocop-on-rbs/blob/main/docs/modules/ROOT/pages/cops.adoc

RBS/Layout:
Enabled: true

RBS/Lint:
Enabled: true

RBS/Style:
Enabled: true
YAML

if github_account
github_account = github_account.sub('@', '')
put base.parent / '_reviewers.yaml', <<~YAML
Expand Down