view vera/rules/L005.tcl @ 680:900ca2f95838

Irccd: do not allow multiple server with same name
author David Demelier <markand@malikania.fr>
date Thu, 12 Apr 2018 20:45:02 +0200
parents 6ec510722582
children
line wrap: on
line source

#!/usr/bin/tclsh
# 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
    }
}