Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Rails: rubocop disable Class has too many lines error

I have a class with constants, many constants. And rubocop is complaining about the length of this Class, which I don't care how long it gets.

I want to disable rubocop's error: "Class has too many lines" but the following is not working:

# rubocop:disable ClassLength

Also, the following isn't either:

# rubocop:disable Metrics/ClassLength

What is the correct metric that I need to disable?

like image 339
fedest Avatar asked Oct 24 '16 15:10

fedest


4 Answers

Try

class Xzy  # rubocop:disable Metrics/ClassLength
like image 125
AnoE Avatar answered Nov 20 '22 10:11

AnoE


when disabling, be sure to enable again

# rubocop:disable ClassLength
class LongClass
end
# rubocop:enable ClassLength

references:

  1. rubocop/lib/rubocop/cop/metrics/class_length.rb

  2. disabling-cops-within-source-code

like image 43
SMAG Avatar answered Nov 20 '22 11:11

SMAG


in .rubocop.yml:

Metrics/MethodLength:
  Max: 1000
like image 16
prograils Avatar answered Nov 20 '22 12:11

prograils


Or in .rubocop.yml:

Metrics/ClassLength:
  Exclude:
    - "path/to/your/file.rb"
like image 14
Dorian Avatar answered Nov 20 '22 11:11

Dorian