elvis_core icon indicating copy to clipboard operation
elvis_core copied to clipboard

New rule: Redundant Blank Lines

Open paulo-ferraz-oliveira opened this issue 1 year ago • 2 comments

Name

redundant_blank_lines

Brief Description

Files should not have two or more consecutive blank lines.

Reasoning

This is not a technical concern, but you can improve the odds of others reading and liking your code by making it easier to follow.

Refactoring Proposal

elvis should warn that multiple blank lines are found in a given file (even if they are made up of trailing whitespace)

Options

max_lines (defaults to 1) should determine the number of consecutive blank lines that are allowed (1 means that a warning would occur for 2 blank lines in a row).

Note: if you're using a formatter, this could/should be a concern for it, also.

Origin (#281)

Inspired by Credo's https://hexdocs.pm/credo/Credo.Check.Readability.RedundantBlankLines.html.

paulo-ferraz-oliveira avatar Mar 01 '23 13:03 paulo-ferraz-oliveira

Don't forget to put an option to specify how many lines are too many lines ;)

elbrujohalcon avatar Mar 01 '23 14:03 elbrujohalcon

Oh, Ok. I though two lines in a row would be too many already. (edit: edited the description, above)

paulo-ferraz-oliveira avatar Mar 01 '23 15:03 paulo-ferraz-oliveira