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.'
Asked
Active
Viewed 1,733 times
0
-
Prefer if or else constructs instead. – Aleksei Matiushkin Aug 10 '16 at 13:40
2 Answers
1
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.

Aleksei Matiushkin
- 119,336
- 10
- 100
- 160
0
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.

koffeinfrei
- 1,985
- 13
- 19