1
0
mirror of https://github.com/RIOT-OS/RIOT.git synced 2024-12-29 04:50:03 +01:00
RIOT/dist/tools/vera++/scripts/rules/T009.tcl
2020-02-14 14:17:16 +01:00

27 lines
1.1 KiB
Tcl
Executable File

#!/usr/bin/tclsh
# Comma should not be preceded by whitespace, but should be followed by one
foreach f [getSourceFileNames] {
foreach t [getTokens $f 1 0 -1 -1 {comma}] {
set line [lindex $t 1]
set column [lindex $t 2]
set preceding [getTokens $f $line 0 $line $column {}]
if {$preceding == {}} {
report $f $line "comma should not be preceded by whitespace"
} else {
set lastPreceding [lindex [lindex $preceding end] 3]
if {$lastPreceding == "space"} {
report $f $line "comma should not be preceded by whitespace"
}
}
set following [getTokens $f $line [expr $column + 1] [expr $line + 1] -1 {}]
if {$following != {}} {
set firstFollowing [lindex [lindex $following 0] 3]
if {$firstFollowing != "space" && $firstFollowing != "newline" &&
!($lastPreceding == "operator" && $firstFollowing == "leftparen")} {
report $f $line "comma should be followed by whitespace"
}
}
}
}