0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

最新のrubocopを使いたい

0
Last updated at Posted at 2021-07-18

かなり古いバージョンのrubocopを使っていたが、
最新版を使ってみたくなった

意外と躓いたので備忘としてメモを残しておく

導入

gemのインストール

Gemfileに以下を記載
念のためバージョンは指定しておく

gem 'rubocop', '~> 1.18', require: false

rubocopの拡張機能も同時に入れる

# rails用の拡張
gem 'rubocop-rails', require: false

# パフォーマンス低下に繋がるcopを指摘してくれる拡張
gem 'rubocop-performance', require: false

# rspec用の拡張
gem 'rubocop-rspec', require: false

rubocop.ymlを設定する

インストールした拡張機能の設定をする

require:
  - rubocop-rails
  - rubocop-rspec
  - rubocop-performance

除外したいものを設定

Exclude:
  - 'vendor/**/*'
  - 'bin/**/*'
  - 'db/**/*'
  - 'tmp/**/*'
  - 'node_modules/**/*'

The following cops were added to RuboCop, but are not configured.と言われた場合

指摘されている内容を個別にrubocop.ymlに書くか
以下のようにすべての設定を一括で設定する

AllCops:
  NewCops: enable

使用方法

// auto-correctしたい場合
bundle exec rubocop -a

// 内容だけ見たい場合
bundle exec rubocop
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?