how to fix Line is too long error in a ruby file without ignoring it and not introducing new errors. I have tried giving the extra character in the next line using IDE. It is introducing new errors like 'Ternary operators must not be nested. Prefer if or else constructs instead.'
Rubocop already suggested the way to fix this error. Let me repeat it here. Assuming you have a very long line that reads:
variable = long_condition ? true_clause : false_clause
change it to:
variable = if long_condition
true_clause
else
false_clause
end
Other way would be to instruct rubocop
to [temporary] ignore this error by running from the very project directory:
rubocop --auto-gen-config
Or, as last but not the least chance, update your .rubocop.yml
file to increase a line length within a respective rule.
Rubocop tells you what to do, just follow its advice.
Also, have a look at the ruby styleguide , which explains all the rubocop rules in detail.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.