What do you think about the length of line


There is a convention that say a line should do 80 characters or less. Thoughbot does not seems to use this convention. For example, upcase/video.rb at master · thoughtbot/upcase · GitHub do 131 charaters.

In addition, long lines are uggly in vim. Should I just don’t care?


That line should absolutely be broken up. If I needed to change that class at some point, I’d definitely change that. We do try to stay within 80 characters as not only are long lines ugly, they are difficult to parse. Here is our style guide. It’s just a guide. Sometimes things are just better on one line, but the example you cited isn’t one of those times.

There are many lines with more than 80 characters like this one : upcase/video.rb at master · thoughtbot/upcase · GitHub or this other one : upcase/users_controller.rb at master · thoughtbot/upcase · GitHub or in this file : github.com/thoughtbot/learn/blob/master/app/controllers/follow_ups_controller.rb.

If you change the code to do smaller line, please let me know.

In my project, to do smaller lines, I do code like this :

def order_creator
@order_creator ||= OrderCreator.new(form: form,
                                    painting: painting,
                                    ip_address: ip_address)

I think it’s a little bit uggly. It’s worse in views. I have code like this :

<%= f.association :painting_technic,
  input_html: { 'data-bind' => "options: availableTechnics,
                 optionsText: 'title',
                 optionsValue: 'id',
                 optionsCaption: ' ',
                 value: painting_technic_id,
                 enable: painting_category_id" } %>

How do you split this kind of code?

I think I’d split my lines the same way you have in these examples.

If you’d like to submit a pull request to the learn app with the lines wrapped better, I’ll merge it. :slight_smile:

I will be happy to contribute to one of your projects. If I find the time, I will do it.

I already did it. I haven’t broke up the lines with 90/93 characters as they look ok to me. Should do those too?

Nah, I wouldn’t worry about them too much.