User7354632781
User7354632781

Reputation: 2274

How to fix "line is too long" error given by lint command

My lint program says this line is too long:

@abc = @def.model_name.where(id: @ghi.id).sum(:jkl) unless @ghi.blank?

How can I fix it?

Upvotes: 0

Views: 5322

Answers (2)

Max Woolf
Max Woolf

Reputation: 4058

The solution is to make the line shorter.

unless @ghi.blank?
  @abc = @def.model_name
             .where(id: @ghi.id)
             .sum(:jkl) 
end

This would be the generally accepted way of shortening the lines without refactoring more widely.

Also, it's just a linter. Your code will still work if you don't do as it says, it'll just be less readable.

Upvotes: 2

User7354632781
User7354632781

Reputation: 2274

Took me a while but fixed it

@abc = @def.model_name.where(
         id: @ghi.id).sum(:jkl) unless @ghi.blank?

Upvotes: 2

Related Questions