Fix 'Line is too long error' in a ruby file


#1



fix 'Line is too long error' in a ruby file

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.'


Replace this line with your code. 
 creation_time: instance.respond_to?(:creation_time) ? (instance.creation_time.respond_to?(:to_hash) ? instance.creation_time.to_hash : instance.creation_time) : nil,


#2

These are warnings, not the errors, right?

If you want to fix both of them you can simply use if else constructions.


You usually want to avoid long lines because they are simply harder to read.

And nested ternary operators decrease readability of your code.


#3

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.