Rubocop - disable long length for commented code
Layout/LineLength:
Max: 150 (for example)
or disable this cop at all
Layout/LineLength:
Enabled: false
or there is an option to ignore lines which start from certain character:
Metrics/LineLength:
Max: 80
IgnoredPatterns: ['(\A|\s)#']
RuboCop: Line is too long ← How to Ignore?
In your code, you can disable a bunch of lines like this:
# rubocop:disable Layout/LineLength
puts "This line is lonnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnng"
# rubocop:enable Layout/LineLength
Or add this to your .rubocop.yml
file to increase the max length:
Layout/LineLength:
Max: 100
Rubocop, how to Disable/Enable cops on blocks of code
I answer my question because it is always very difficult for me to find the reference to this solution:
# rubocop:disable Metrics/MethodLength
def my_code
..
end
# rubocop:enable Metrics/MethodLength
Same for multiple cops:
# rubocop:disable Metrics/AbcSize, Metrics/MethodLength
def my_code
..
end
# rubocop:enable Metrics/AbcSize, Metrics/MethodLength
Documentation: https://docs.rubocop.org/rubocop/configuration.html#disabling-cops-within-source-code
Remove rubocop comments from Yardoc documentation
To disable rubocop directives in the code from appearing in YARDOC documentation insert a newline after the comment. e.g.
# rubocop:disable Metrics/AbcSize
# Converts the object into textual markup given a specific format.
#
# @param format [Symbol] the format type, `:text` or `:html`
# @return [String] the object converted into the expected format.
def to_format(format = :html)
# format the object
end
If a Rubocop rule is disabled in-line does it need to be re-enabled
In-line config is applied to the given file only (just tested it).
Rails: rubocop disable Class has too many lines error
Try
class Xzy # rubocop:disable Metrics/ClassLength
Rails: rubocop disable Class has too many lines error
Try
class Xzy # rubocop:disable Metrics/ClassLength
Related Topics
Trying to Install Rails- Eisdir Error
Ruby Array to String Conversion
All Ruby Tests Raising: Undefined Method 'Authenticate' for Nil:Nilclass
Ruby: How to Get the First Character of a String
Why Do I Need to Work Harder to Make My Rails Application Fit into a Restful Architecture
Engine's Assets with Rails 3.1
Rails: Custom Text for Rails Form_For Label
Concatenating String with Number in Ruby
Using Ruby Libraries and Gems with a Shoes App
Can't Install Ruby-Debug-Base19X Gem
Unknown Ruby Interpreter Version (Do Not Know How to Handle): Ruby_Version
What Is Mattr_Accessor in a Rails Module
Measure and Benchmark Time for Ruby Methods
Disable a Group of Tests in Rspec
Ruby Way to Generate a Hmac-Sha1 Signature for Oauth
How to Calculate the Offset, in Hours, of a Given Timezone from Utc in Ruby
Reraise (Same Exception) After Catching an Exception in Ruby
How to Convert an Array of Strings into a Comma-Separated String