L005
There should not be too many consecutive empty lines
Description:
The empty lines (if any) help to introduce more "light" in the source code, but they should not be overdosed in the sense that too many consecutive empty lines make the code harder to follow.
Lines containing only whitespace are considered to be empty in this context.
Recognized parameters:
Name | Default | Description |
---|
max-consecutive-empty-lines | 2 | Maximum number of consecutive empty lines. |
Compliance: Inspirel
Hide source code
# There should not be too many consecutive empty lines
set maxEmptyLines [getParameter "max-consecutive-empty-lines" 2]
foreach f [getSourceFileNames] {
set lineNumber 1
set emptyCount 0
set reported false
foreach line [getAllLines $f] {
if {[string trim $line] == ""} {
incr emptyCount
if {$emptyCount > $maxEmptyLines && $reported == "false"} {
report $f $lineNumber "too many consecutive empty lines"
set reported true
}
} else {
set emptyCount 0
set reported false
}
incr lineNumber
}
}
Rule index