How to disable sorting gem names in Gemfile in Rubocop?

234 Views Asked by At

I'm coming into a legacy code base which had no style guide. So as to no introduce too many changes, is there a way to by pass this check? https://www.rubydoc.info/gems/rubocop/RuboCop/Cop/Bundler/OrderedGems looking at docs and repo didn't yield a solution and trying to exclude Gemfile in rubocop.yml didn't work either.

AllCops:                                                                                                                                                                                     
  NewCops: enable                                                                                                                                                                                
  Exclude:                                                                                                                                                                                         
    - Gemfile
1

There are 1 best solutions below

6
anothermh On

Add an exclusion for the Bundler::OrderedGems cop to .rubocop.yml:

Bundler/OrderedGems:
  Enabled: false

Before:

$ bin/rubocop Gemfile
Inspecting 1 file
C

Offenses:

Gemfile:14:1: C: [Correctable] Bundler/OrderedGems: Gems should be sorted in an alphabetical order within their section of the Gemfile. Gem puma should appear before rails.
gem 'puma'
^^^^^^^^^^

1 file inspected, 1 offense detected, 1 offense autocorrectable

After:

$ bin/rubocop Gemfile
Inspecting 1 file
.

1 file inspected, no offenses detected