History

checkpatch: additional MAINTAINER section entry ordering checks

There is a preferred order for the entries in MAINTAINERS sections. See commits 3b50142d8528 ("MAINTAINERS: sort field names for all entries") and 6680125ea5a2 ("MAINTAINERS: list the section entries in the preferred order") Add checkpatch tests to try to keep that ordering.

Joe Perches committed 6 years ago

Commit 7ccf41a1 parent bd93f001 file · +37 −8Browse files

Showing the changes to scripts/checkpatch.pl (1 of 1 file). Show all

Unified · Split

scripts/checkpatch.pl+37−8
@@ -3062,14 +3062,43 @@ sub process { · 3061 unmodified lines
3062 #print "is_start<$is_start> is_end<$is_end> length<$length>\n";3062 #print "is_start<$is_start> is_end<$is_end> length<$length>\n";
3063 }3063 }
3064 3064
3065# check for MAINTAINERS entries that don't have the right form3065# check MAINTAINERS entries
3066 if ($realfile =~ /^MAINTAINERS$/ &&3066 if ($realfile =~ /^MAINTAINERS$/) {
3067 $rawline =~ /^\+[A-Z]:/ &&3067# check MAINTAINERS entries for the right form
3068 $rawline !~ /^\+[A-Z]:\t\S/) {3068 if ($rawline =~ /^\+[A-Z]:/ &&
3069 if (WARN("MAINTAINERS_STYLE",3069 $rawline !~ /^\+[A-Z]:\t\S/) {
3070 "MAINTAINERS entries use one tab after TYPE:\n" . $herecurr) &&3070 if (WARN("MAINTAINERS_STYLE",
3071 $fix) {3071 "MAINTAINERS entries use one tab after TYPE:\n" . $herecurr) &&
3072 $fixed[$fixlinenr] =~ s/^(\+[A-Z]):\s*/$1:\t/;3072 $fix) {
3073 $fixed[$fixlinenr] =~ s/^(\+[A-Z]):\s*/$1:\t/;
3074 }
3075 }
3076# check MAINTAINERS entries for the right ordering too
3077 my $preferred_order = 'MRLSWQBCPTFXNK';
3078 if ($rawline =~ /^\+[A-Z]:/ &&
3079 $prevrawline =~ /^[\+ ][A-Z]:/) {
3080 $rawline =~ /^\+([A-Z]):\s*(.*)/;
3081 my $cur = $1;
3082 my $curval = $2;
3083 $prevrawline =~ /^[\+ ]([A-Z]):\s*(.*)/;
3084 my $prev = $1;
3085 my $prevval = $2;
3086 my $curindex = index($preferred_order, $cur);
3087 my $previndex = index($preferred_order, $prev);
3088 if ($curindex < 0) {
3089 WARN("MAINTAINERS_STYLE",
3090 "Unknown MAINTAINERS entry type: '$cur'\n" . $herecurr);
3091 } else {
3092 if ($previndex >= 0 && $curindex < $previndex) {
3093 WARN("MAINTAINERS_STYLE",
3094 "Misordered MAINTAINERS entry - list '$cur:' before '$prev:'\n" . $hereprev);
3095 } elsif ((($prev eq 'F' && $cur eq 'F') ||
3096 ($prev eq 'X' && $cur eq 'X')) &&
3097 ($prevval cmp $curval) > 0) {
3098 WARN("MAINTAINERS_STYLE",
3099 "Misordered MAINTAINERS entry - list file patterns in alphabetic order\n" . $hereprev);
3100 }
3101 }
3073 }3102 }
3074 }3103 }
3075 3104