elvis_core icon indicating copy to clipboard operation
elvis_core copied to clipboard

New rule: Consistent Trailing Blank Line

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

Name

consistent_trailing_blank_line

Brief Description

Files should end in a single trailing blank line.

Reasoning

This is mostly for historical reasons: every text file should end with a \n, or newline since this acts as eol or the end of the line character.

See also: http://pubs.opengroup.org/onlinepubs/9699919799/basedefs/V1_chap03.html#tag_03_206

Most text editors ensure this "final newline" automatically.

Refactoring Proposal

elvis should warn when such a line is missing or when multiple lines are present.

Note: this can also be considered a formatter issue, so shouldn't exist in your code base if you're using such an element.

Options

style should be either windows or unix (for \r\n, or \n)

Origin (#281)

Inspired by Credo's Credo.Check.Readability.TrailingBlankLine.

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

Don't forget to add an option to specify the expected trailing line style.

elbrujohalcon avatar Mar 01 '23 14:03 elbrujohalcon

You mean like \n or \r\n? (edit: check the description above)

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

Yeah.

elbrujohalcon avatar Mar 01 '23 15:03 elbrujohalcon