Ruby - rubocop Method too long

If you only care about the SketchUp suggestion you can disable all the default rules RuboCop comes with. It’s described here:

require: rubocop-sketchup

AllCops:
  DisabledByDefault: true
  DisplayStyleGuide: true
  SketchUp:
    SourcePath: src # Path to extension sources in project directory.
    EncryptedExtension: false # Enable if you plan to encrypt your extension.
    TargetSketchUpVersion: 2016 M1

SketchupDeprecations:
  Enabled: true

SketchupPerformance:
  Enabled: true

SketchupRequirements:
  Enabled: true

SketchupSuggestions:
  Enabled: true

SketchupBugs:
  Enabled: true

RuboCop is very opinionated. Some things are way too subjective for my taste. I use a relaxed version, which you can see in the rubocop-sketchup repository: https://github.com/SketchUp/rubocop-sketchup/blob/master/sketchup-style.yml

Because I work on a bunch of projects I’ve started to maintain that config file as the main style guide. RuboCop allows you to refer to external config files via URL. See TrueBend as an example:

There are other relaxed style guides out there, this one for instance:

Agree. Though I still have a max-cap set to 20 or 30 to make me think if I end up with methods larger than this. If they warrant it I’ll disable the warning locally for the method only.

Linters are very powerful, and very useful to enforce consistent styles across a code base. But never accept the default blindly. Especially if you are retro-fitting such a tool to an existing code base if can be a large amount of work to make it comply. Evaluate what these tools suggest and turn off what you judge to not be beneficial for you. (This is the reason the example config for rubocop-sketchup turns off all other default cops - it can be overwhelming.)

2 Likes