Rubocop: No way to disable Metrics/LineLength for shebang line

Created on 11 Jun 2019  路  3Comments  路  Source: rubocop-hq/rubocop

Is your feature request related to a problem? Please describe.

I don't think I can disable the Metrics/LineLength for just the shebang line.

(If it helps, the shebang line in question is #!/System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/bin/ruby --disable-gems. The reason I'm doing this is to reference the system Ruby on macOS while bypassing the users gem environment.)

Describe the solution you'd like

I'd like to be able to disable Metrics/LineLength for just the shebang line. Really I think this should be Rubocops default behavior, Metrics/LineLength shouldn't apply to a shebang line because it's not Ruby source code, and it can't reliably be shortened. But if it were a configuration option, I'd say having a syntax for it in disabling cops within source code would be nice.

Thanks!

enhancement

Most helpful comment

The Metrics/LineLength cop can be configured to ignore lines that match certain patterns. Maybe that would help you?

Metrics/LineLength:
  IgnoredPatterns:
    - ^#!

All 3 comments

The Metrics/LineLength cop can be configured to ignore lines that match certain patterns. Maybe that would help you?

Metrics/LineLength:
  IgnoredPatterns:
    - ^#!

@buehmann Thanks Andreas! I tried this approach out and it seems like a good workaround for my situation. I still think ideally the shebang should be ignored by default, so I'll leave the issue open for however the maintainers want to handle it. Thanks and cheers!

@robenkleene You're welcome. And I have good news: I saw this PR this morning: https://github.com/rubocop-hq/rubocop/pull/7232

Was this page helpful?
0 / 5 - 0 ratings

Related issues

mlammers picture mlammers  路  3Comments

benoittgt picture benoittgt  路  3Comments

cabello picture cabello  路  3Comments

mikegee picture mikegee  路  3Comments

bbugh picture bbugh  路  3Comments