util/lint: maintainers-syntax: Add a check to ensure paths exist

The MAINTAINERS file is used to automatically assign reviewers on
Gerrit, however as the paths are not checked they can become out of
sync with the codebase. This is detrimental to both the uploader
and the maintainers, as the change may not get the appropriate
attention.

Fix this problem by adding a simple check for 'F' and 'X' entries.

Change-Id: I7755f6317edda0d8d976e138cfafcc3ef5850ead
Signed-off-by: Nicholas Sudsgaard <devel+coreboot@nsudsgaard.com>
Reviewed-on: https://review.coreboot.org/c/coreboot/+/89511
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Elyes Haouas <ehaouas@noos.fr>
Reviewed-by: Angel Pons <th3fanbus@gmail.com>
This commit is contained in:
Nicholas Sudsgaard 2025-10-10 09:15:01 +09:00 committed by Matt DeVillier
commit d23eaa356f

View file

@ -1,21 +1,34 @@
#!/usr/bin/env perl
# SPDX-License-Identifier: GPL-2.0-or-later
#
# DESCR: Check that path patterns in MAINTAINERS have trailing slash
# DESCR: Check the syntax of the MAINTAINERS file
use strict;
use warnings;
sub check_path {
my ($path) = @_;
if ( ! -e $path ) {
print "MAINTAINERS:$. No such file or directory exists ";
print "`$path`\n";
}
}
open( my $file, "<", "MAINTAINERS" ) or die "Error: could not open file 'MAINTAINERS'\n";
while ( my $line = <$file> ) {
if ( $line =~ /^[FX]:\s+([^\s]*[^*\/\s])\s+$/ ) { # path patterns not ending with / or *
if ( $line =~ /^[FX]:\s+([^\s]*)\s+$/ ) {
my $path = $1;
if ( -d $path ) {
# Match path patterns not ending with '/' or '*'. This cannot be done
# in check_path(), as it only works on pre-globbed paths.
if ( $path =~ /[^*\/\s]$/ && -d $path ) {
print "MAINTAINERS:$. missing trailing slash for directory match ";
print "`$path`\n";
}
check_path($_) foreach ( glob $path );
}
}