Currently this test only works on .[ch] files. Move the test to check more file types and the commit log.
Showing the changes to scripts/checkpatch.pl (1 of 1 file). Show all
Unified · Split
| @@ -2991,6 +2991,42 @@ sub process { · 2990 unmodified lines | ||
| 2991 | 2991 | } |
| 2992 | 2992 | } |
| 2993 | 2993 | |
| 2994 | +# check for repeated words separated by a single space | |
| 2995 | + if ($rawline =~ /^\+/ || $in_commit_log) { | |
| 2996 | + while ($rawline =~ /\b($word_pattern) (?=($word_pattern))/g) { | |
| 2997 | + | |
| 2998 | + my $first = $1; | |
| 2999 | + my $second = $2; | |
| 3000 | + | |
| 3001 | + if ($first =~ /(?:struct|union|enum)/) { | |
| 3002 | + pos($rawline) += length($first) + length($second) + 1; | |
| 3003 | + next; | |
| 3004 | + } | |
| 3005 | + | |
| 3006 | + next if ($first ne $second); | |
| 3007 | + next if ($first eq 'long'); | |
| 3008 | + | |
| 3009 | + if (WARN("REPEATED_WORD", | |
| 3010 | + "Possible repeated word: '$first'\n" . $herecurr) && | |
| 3011 | + $fix) { | |
| 3012 | + $fixed[$fixlinenr] =~ s/\b$first $second\b/$first/; | |
| 3013 | + } | |
| 3014 | + } | |
| 3015 | + | |
| 3016 | + # if it's a repeated word on consecutive lines in a comment block | |
| 3017 | + if ($prevline =~ /$;+\s*$/ && | |
| 3018 | + $prevrawline =~ /($word_pattern)\s*$/) { | |
| 3019 | + my $last_word = $1; | |
| 3020 | + if ($rawline =~ /^\+\s*\*\s*$last_word /) { | |
| 3021 | + if (WARN("REPEATED_WORD", | |
| 3022 | + "Possible repeated word: '$last_word'\n" . $hereprev) && | |
| 3023 | + $fix) { | |
| 3024 | + $fixed[$fixlinenr] =~ s/(\+\s*\*\s*)$last_word /$1/; | |
| 3025 | + } | |
| 3026 | + } | |
| 3027 | + } | |
| 3028 | + } | |
| 3029 | + | |
| 2994 | 3030 | # ignore non-hunk lines and lines being removed |
| 2995 | 3031 | next if (!$hunk_line || $line =~ /^-/); |
| 2996 | 3032 | |
| @@ -3314,42 +3350,6 @@ sub process { · 317 unmodified lines | ||
| 3314 | 3350 | } |
| 3315 | 3351 | } |
| 3316 | 3352 | |
| 3317 | −# check for repeated words separated by a single space | |
| 3318 | − if ($rawline =~ /^\+/) { | |
| 3319 | − while ($rawline =~ /\b($word_pattern) (?=($word_pattern))/g) { | |
| 3320 | − | |
| 3321 | − my $first = $1; | |
| 3322 | − my $second = $2; | |
| 3323 | − | |
| 3324 | − if ($first =~ /(?:struct|union|enum)/) { | |
| 3325 | − pos($rawline) += length($first) + length($second) + 1; | |
| 3326 | − next; | |
| 3327 | − } | |
| 3328 | − | |
| 3329 | − next if ($first ne $second); | |
| 3330 | − next if ($first eq 'long'); | |
| 3331 | − | |
| 3332 | − if (WARN("REPEATED_WORD", | |
| 3333 | − "Possible repeated word: '$first'\n" . $herecurr) && | |
| 3334 | − $fix) { | |
| 3335 | − $fixed[$fixlinenr] =~ s/\b$first $second\b/$first/; | |
| 3336 | − } | |
| 3337 | − } | |
| 3338 | − | |
| 3339 | − # if it's a repeated word on consecutive lines in a comment block | |
| 3340 | − if ($prevline =~ /$;+\s*$/ && | |
| 3341 | − $prevrawline =~ /($word_pattern)\s*$/) { | |
| 3342 | − my $last_word = $1; | |
| 3343 | − if ($rawline =~ /^\+\s*\*\s*$last_word /) { | |
| 3344 | − if (WARN("REPEATED_WORD", | |
| 3345 | − "Possible repeated word: '$last_word'\n" . $hereprev) && | |
| 3346 | − $fix) { | |
| 3347 | − $fixed[$fixlinenr] =~ s/(\+\s*\*\s*)$last_word /$1/; | |
| 3348 | − } | |
| 3349 | − } | |
| 3350 | − } | |
| 3351 | − } | |
| 3352 | − | |
| 3353 | 3353 | # check for space before tabs. |
| 3354 | 3354 | if ($rawline =~ /^\+/ && $rawline =~ / \t/) { |
| 3355 | 3355 | my $herevet = "$here\n" . cat_vet($rawline) . "\n"; |