From 10d34b7818350ed5b7c857c96439755a73f9218d Mon Sep 17 00:00:00 2001 From: Martin Roth Date: Tue, 22 Mar 2022 16:24:44 -0600 Subject: util/lint/checkpatch: Update commit message & subject line limits The commit message has a (soft) line length limit of 72 characters and the subject has a (soft) line limit of 65 characters. This change updates checkpatch to warn at those limits. Note that neither of these are hard limits because git & gerrit can both handle longer lines, it just doesn't look good. Change-Id: I4ef131a65254e2b184b05e0215969aef97e12712 Signed-off-by: Martin Roth Reviewed-on: https://review.coreboot.org/c/coreboot/+/63029 Tested-by: build bot (Jenkins) Reviewed-by: Paul Menzel Reviewed-by: Elyes Haouas Reviewed-by: Felix Singer --- util/lint/checkpatch.pl | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) (limited to 'util/lint') diff --git a/util/lint/checkpatch.pl b/util/lint/checkpatch.pl index 3cf249c4ed..93551862b2 100755 --- a/util/lint/checkpatch.pl +++ b/util/lint/checkpatch.pl @@ -2265,7 +2265,6 @@ sub process { my $in_commit_log = 0; #Scanning lines before patch my $has_commit_log = 0; #Encountered lines before patch my $commit_log_possible_stack_dump = 0; - my $commit_log_long_line = 0; my $commit_log_has_diff = 0; my $reported_maintainer_file = 0; my $non_utf8_charset = 0; @@ -2658,10 +2657,9 @@ sub process { $commit_log_possible_stack_dump = 1; } -# coreboot: The line lengeth limit is 72 -# Check for line lengths > 72 in commit log, warn once - if ($in_commit_log && !$commit_log_long_line && - length($line) > 72 && +# coreboot: The line length limit is 72 +# Check for line lengths > 72 in commit log + if ($in_commit_log && length($line) > 72 && !($line =~ /^\s*[a-zA-Z0-9_\/\.]+\s+\|\s+\d+/ || # file delta changes $line =~ /^\s*(?:[\w\.\-\+]*\/)++[\w\.\-\+]+:/ || @@ -2671,7 +2669,18 @@ sub process { $commit_log_possible_stack_dump)) { WARN("COMMIT_LOG_LONG_LINE", "Possible unwrapped commit description (prefer a maximum 72 chars per line)\n" . $herecurr); - $commit_log_long_line = 1; + } + +# coreboot: The line subject limit is 65 +# Check for line lengths > 65 in commit subject + if ($in_header_lines && + $line =~ /^Subject: /) { + $line = $line.$rawlines[$linenr]; + $line =~ s/^Subject: \[PATCH\] //; + if (length($line) > 65) { + WARN("COMMIT_LOG_LONG_LINE", + "Possible long commit subject (prefer a maximum 65 characters)\n" . $herecurr); + } } # Reset possible stack dump if a blank line is found -- cgit v1.2.3