title: Why is a method with too many lines a bad thing?
body: <p>In my rails app, I have a method like this:</p>
  
  <pre><code>def cart
      if user_signed_in?
          @user = current_user
          if @user.cart.present?
              @cart = @user.cart
          else
              @cart = false
          end
      else
          cart_id = session[:cart_id]
  
          if cart_id.present?
              @cart = Cart.find(cart_id.to_i)
          else
              @cart = false
          end
      end
  end
  </code></pre>
  
  <p>Rubocop flagged this method as <code>Method had too many lines</code>. Why is it bad to write a method with too many lines? What if we have to do a lot of work in it? How can I re-factor this and write good code?</p>