checksrc: disallow spaces before labels
Out of 415 labels throughout the code base, 86 of those labels were not at the start of the line. Which means labels always at the start of the line is the favoured style overall with 329 instances. Out of the 86 labels not at the start of the line: * 75 were indented with the same indentation level of the following line * 8 were indented with exactly one space * 2 were indented with one fewer indentation level then the following line * 1 was indented with the indentation level of the following line minus three space (probably unintentional) Co-Authored-By: Viktor Szakats Closes #11134
This commit is contained in:
parent
d334b02924
commit
f198d33e8d
@ -75,6 +75,7 @@ my %warnings = (
|
||||
'INCLUDEDUP', => 'same file is included again',
|
||||
'INDENTATION' => 'wrong start column for code',
|
||||
'LONGLINE' => "Line longer than $max_column",
|
||||
'SPACEBEFORELABEL' => 'labels not at the start of the line',
|
||||
'MULTISPACE' => 'multiple spaces used when not suitable',
|
||||
'NOSPACEEQUALS' => 'equals sign without preceding space',
|
||||
'NOTEQUALSZERO', => 'if/while comparison with != 0',
|
||||
@ -697,6 +698,11 @@ sub scanfile {
|
||||
$line, length($1), $file, $ol, "no space before colon of switch label");
|
||||
}
|
||||
|
||||
if($prevl !~ /\?\z/ && $l =~ /^ +([A-Za-z_][A-Za-z0-9_]*):$/ && $1 ne 'default') {
|
||||
checkwarn("SPACEBEFORELABEL",
|
||||
$line, length($1), $file, $ol, "no space before label");
|
||||
}
|
||||
|
||||
# scan for use of banned functions
|
||||
if($l =~ /^(.*\W)
|
||||
(gmtime|localtime|
|
||||
|
||||
Loading…
Reference in New Issue
Block a user