Help us understand the problem. What is going on with this article?

CircleCIでのみrubocopがエラーになる

More than 1 year has passed since last update.

現象

手元の開発環境ではrubocopに怒られない。

% bundle exec rubocop
Inspecting 31 files
...............................

31 files inspected, no offenses detected

だがしかし、CircleCIのコンテナで動かすとエラーになる!

スクリーンショット 2018-06-25 15.26.38.png

#!/bin/bash -eo pipefail
bundle exec rubocop
Error: The `Style/TrailingCommaInLiteral` cop no longer exists. Please use `Style/TrailingCommaInArrayLiteral` and/or `Style/TrailingCommaInHashLiteral` instead.
(obsolete configuration found in vendor/bundle/ruby/2.5.0/gems/public_suffix-3.0.2/.rubocop_defaults.yml, please update it)
Exited with code 2

原因

理由は簡単だった。bundle installしたgemsは手元ではシステム(というかrbenv)の配下にロードされるのに対して、CircleCIではvendor/bundle配下にロードするように指定してあった。

- run:
    name: install dependencies
    command: |
      yarn install
      bundle install --jobs=4 --retry=3 --path vendor/bundle

このためrubocopがvendor配下のgemsたちまでチェックしてしまっていたのだった。

対策

vendor配下をrubocopの対象外にすることで解決した。

AllCops:
  TargetRubyVersion: 2.5
  Exclude:
    - 'bin/**/*'
    - 'node_modules/**/*'
    - 'vendor/**/*'

参考

https://tosbourn.com/rubocop-circleci-config/

Why do not you register as a user and use Qiita more conveniently?
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
Comments
Sign up for free and join this conversation.
If you already have a Qiita account
Why do not you register as a user and use Qiita more conveniently?
You need to log in to use this function. Qiita can be used more conveniently after logging in.
You seem to be reading articles frequently this month. Qiita can be used more conveniently after logging in.
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away