How to make Rubocop ignore the Gemfile.lock

251 Views Asked by At

I am trying to get Rubocop running but I am not able to ignore the Gemfile.lock file from the Rubocop configuration.

I am working with a bit of a legacy Rails code base and am trying to get Rubocop running. In my .rubocop.yml file I have:

AllCops:
  Exclude:
    - Gemfile.lock

However when I run rubocop it complains about things in Gemfile.lock If I run rubocop --force-exclusion Gemfile.lock then it successfully ignores the Gemfile.lock What am I doing wrong in the config file?

My version of Ruby is '2.4.10', Rails: '4.2.11.3' and Rubocop '1.12.1'

1

There are 1 best solutions below

2
Umar Bhai On

By default, rubocop does not check gemfile.lock. So there is no need to add it in Exclude block. Check your .rubocop_todo.yml file for any configration erros. Ensure that you haven't explicitly configured RuboCop to analyze the Gemfile.lock file.

Last solution is to add:

rubocop:disable all

on top of your gemfile.lock, so rubocop will always ignore this file.