From 2d28d5d5d46d9830bea58727c03681baeee7feb8 Mon Sep 17 00:00:00 2001 From: Thomas Haller Date: Wed, 11 Jul 2018 08:23:56 +0200 Subject: [PATCH] checkpatch: warn about non-leading tabs Tabs are not only wrong after a space, they are always wrong if they don't appear at the beginning of a line. That would happen usually, when trying to align multiple lines like enum { VALUE1 = 1; OTHER_VALUE = 2; }; When doing that, the alignment will only be correct, if the reader later uses the same tab-width. Note that in NetworkManager we recommend the tab-width to be 4 characters, but with our "smart tab" indentation style, it wouldn't actually matter and the reader is free to choose any other tab-width -- as long as we don't use non-leading tabs. Don't allow non-leading tabs. --- contrib/scripts/checkpatch.pl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/contrib/scripts/checkpatch.pl b/contrib/scripts/checkpatch.pl index 55e08498ad..2556445ce3 100755 --- a/contrib/scripts/checkpatch.pl +++ b/contrib/scripts/checkpatch.pl @@ -117,7 +117,7 @@ if ($is_file and $filename ne $ARGV) { next unless $filename =~ /\.[ch]$/; -complain ('Tab following a space') if $line =~ / \t/; +complain ('Tabs are only allowed at the beginning of a line') if $line =~ /[^\t]\t/; complain ('Trailing whitespace') if $line =~ /[ \t]$/; complain ('Don\'t use glib typedefs for char/short/int/long/float/double') if $line =~ /\bg(char|short|int|long|float|double)\b/;