my %warnings = (
'ASSIGNWITHINCONDITION' => 'assignment within conditional expression',
- 'ASTERISKNOSPACE' => 'pointer declared without space before asterisk',
- 'ASTERISKSPACE' => 'pointer declared with space after asterisk',
- 'BADCOMMAND' => 'bad !checksrc! instruction',
- 'BANNEDFUNC' => 'a banned function was used',
- 'BANNEDPREPROC' => 'a banned symbol was used on a preprocessor line',
- 'BRACEELSE' => '} else on the same line',
- 'BRACEPOS' => 'wrong position for an open brace',
- 'BRACEWHILE' => 'A single space between open brace and while',
- 'COMMANOSPACE' => 'comma without following space',
- 'COMMENTNOSPACEEND' => 'no space before */',
- 'COMMENTNOSPACESTART' => 'no space following /*',
- 'COPYRIGHT' => 'file missing a copyright statement',
- 'CPPCOMMENTS' => '// comment detected',
- 'DOBRACE' => 'A single space between do and open brace',
- 'EMPTYLINEBRACE' => 'Empty line before the open brace',
- 'EQUALSNOSPACE' => 'equals sign without following space',
- 'EQUALSNULL' => 'if/while comparison with == NULL',
- 'EXCLAMATIONSPACE' => 'Whitespace after exclamation mark in expression',
- 'FOPENMODE' => 'fopen needs a macro for the mode string',
- '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',
- 'NOSPACEQ' => 'missing space around ternary question mark operator',
- 'NOSPACETHAN' => 'missing space around less or greater than',
- 'NOTEQUALSZERO', => 'if/while comparison with != 0',
- 'ONELINECONDITION' => 'conditional block on the same line as the if()',
- 'OPENCOMMENT' => 'file ended with a /* comment still "open"',
- 'PARENBRACE' => '){ without sufficient space',
- 'RETURNNOSPACE' => 'return without space',
- 'SEMINOSPACE' => 'semicolon without following space',
- 'SIZEOFNOPAREN' => 'use of sizeof without parentheses',
- 'SNPRINTF' => 'use of snprintf',
- 'SPACEAFTERPAREN' => 'space after open parenthesis',
- 'SPACEBEFORECLOSE' => 'space before a close parenthesis',
- 'SPACEBEFORECOMMA' => 'space before a comma',
- 'SPACEBEFOREPAREN' => 'space before an open parenthesis',
- 'SPACESEMICOLON' => 'space before semicolon',
- 'SPACESWITCHCOLON' => 'space before colon of switch label',
- 'TABS' => 'TAB characters not allowed',
- 'TRAILINGSPACE' => 'Trailing whitespace on the line',
- 'TYPEDEFSTRUCT' => 'typedefed struct',
- 'UNUSEDIGNORE' => 'a warning ignore was not used',
+ 'ASTERISKNOSPACE' => 'pointer declared without space before asterisk',
+ 'ASTERISKSPACE' => 'pointer declared with space after asterisk',
+ 'BADCOMMAND' => 'bad !checksrc! instruction',
+ 'BANNEDFUNC' => 'a banned function was used',
+ 'BANNEDPREPROC' => 'a banned symbol was used on a preprocessor line',
+ 'BRACEELSE' => '} else on the same line',
+ 'BRACEPOS' => 'wrong position for an open brace',
+ 'BRACEWHILE' => 'A single space between open brace and while',
+ 'COMMANOSPACE' => 'comma without following space',
+ 'COMMENTNOSPACEEND' => 'no space before */',
+ 'COMMENTNOSPACESTART' => 'no space following /*',
+ 'COPYRIGHT' => 'file missing a copyright statement',
+ 'CPPCOMMENTS' => '// comment detected',
+ 'DOBRACE' => 'A single space between do and open brace',
+ 'EMPTYLINEBRACE' => 'Empty line before the open brace',
+ 'EQUALSNOSPACE' => 'equals sign without following space',
+ 'EQUALSNULL' => 'if/while comparison with == NULL',
+ 'EXCLAMATIONSPACE' => 'Whitespace after exclamation mark in expression',
+ 'FOPENMODE' => 'fopen needs a macro for the mode string',
+ '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',
+ 'NOSPACEC' => 'missing space around ternary colon operator',
+ 'NOSPACEEQUALS' => 'equals sign without preceding space',
+ 'NOSPACEQ' => 'missing space around ternary question mark operator',
+ 'NOSPACETHAN' => 'missing space around less or greater than',
+ 'NOTEQUALSZERO', => 'if/while comparison with != 0',
+ 'ONELINECONDITION' => 'conditional block on the same line as the if()',
+ 'OPENCOMMENT' => 'file ended with a /* comment still "open"',
+ 'PARENBRACE' => '){ without sufficient space',
+ 'RETURNNOSPACE' => 'return without space',
+ 'SEMINOSPACE' => 'semicolon without following space',
+ 'SIZEOFNOPAREN' => 'use of sizeof without parentheses',
+ 'SNPRINTF' => 'use of snprintf',
+ 'SPACEAFTERPAREN' => 'space after open parenthesis',
+ 'SPACEBEFORECLOSE' => 'space before a close parenthesis',
+ 'SPACEBEFORECOMMA' => 'space before a comma',
+ 'SPACEBEFOREPAREN' => 'space before an open parenthesis',
+ 'SPACESEMICOLON' => 'space before semicolon',
+ 'SPACESWITCHCOLON' => 'space before colon of switch label',
+ 'TABS' => 'TAB characters not allowed',
+ 'TRAILINGSPACE' => 'Trailing whitespace on the line',
+ 'TYPEDEFSTRUCT' => 'typedefed struct',
+ 'UNUSEDIGNORE' => 'a warning ignore was not used',
);
sub readskiplist {
"space after open parenthesis");
}
+ # check spaces before colon
+ if($nostr =~ /^(.*[^']\?[^'].*)(\w|\)|\]|')\:/i) {
+ my $m = $1;
+ my $e = $nostr;
+ $e =~ s/'(.)':'(.)'/$1:$2/g; # eliminate chars quotes that suround colon
+ $e =~ s/':'//g; # ignore these
+ if($e =~ /^(.*[^']\?[^'].*)(\w|\)|\]|')\:/i) {
+ checkwarn("NOSPACEC",
+ $line, length($m)+1, $file, $l,
+ "missing space before colon");
+ }
+ }
+ # check spaces after colon
+ if($nostr =~ /^(.*[^'"]\?[^'"].*)\:(\w|\)|\]|')/i) {
+ my $m = $1;
+ my $e = $nostr;
+ $e =~ s/'(.)':'(.)'/$1:$2/g; # eliminate chars quotes that suround colon
+ $e =~ s/':'//g; # ignore these
+ if($e =~ /^(.*[^'"]\?[^'"].*)\:(\w|\)|\]|')/i) {
+ checkwarn("NOSPACEC",
+ $line, length($m)+1, $file, $l,
+ "missing space after colon");
+ }
+ }
+
# check spaces before question mark
if($nostr =~ /^(.*)(\w|\)|\]|')\?/i) {
my $m = $1;
my $e = $nostr;
$e =~ s/'?'//g; # ignore these
- if($e =~ /^(.*)(\w|\)|')\?/i) {
+ if($e =~ /^(.*)(\w|\)|\]|')\?/i) {
checkwarn("NOSPACEQ",
$line, length($m)+1, $file, $l,
"missing space before question mark");