checkpatch: warn on long summary, commit text lines
Warn on summary or commit text lines greater than 75 characters. The summary and commit text are indented and may wrap on a terminal if they are longer than 75 characters. Signed-off-by: David Keitel <dkeitel@codeaurora.org>
This commit is contained in:
parent
790b5c34d2
commit
acdce03516
1 changed files with 41 additions and 1 deletions
|
@ -11,6 +11,11 @@ use File::Basename;
|
||||||
use Cwd 'abs_path';
|
use Cwd 'abs_path';
|
||||||
use Term::ANSIColor qw(:constants);
|
use Term::ANSIColor qw(:constants);
|
||||||
|
|
||||||
|
use constant BEFORE_SHORTTEXT => 0;
|
||||||
|
use constant IN_SHORTTEXT => 1;
|
||||||
|
use constant AFTER_SHORTTEXT => 2;
|
||||||
|
use constant SHORTTEXT_LIMIT => 75;
|
||||||
|
|
||||||
my $P = $0;
|
my $P = $0;
|
||||||
my $D = dirname(abs_path($P));
|
my $D = dirname(abs_path($P));
|
||||||
|
|
||||||
|
@ -2030,6 +2035,8 @@ sub process {
|
||||||
my $setup_docs = 0;
|
my $setup_docs = 0;
|
||||||
|
|
||||||
my $camelcase_file_seeded = 0;
|
my $camelcase_file_seeded = 0;
|
||||||
|
my $shorttext = BEFORE_SHORTTEXT;
|
||||||
|
my $shorttext_exspc = 0;
|
||||||
|
|
||||||
sanitise_line_reset();
|
sanitise_line_reset();
|
||||||
cleanup_continuation_headers();
|
cleanup_continuation_headers();
|
||||||
|
@ -2216,13 +2223,46 @@ sub process {
|
||||||
}
|
}
|
||||||
next;
|
next;
|
||||||
}
|
}
|
||||||
|
|
||||||
$here .= "FILE: $realfile:$realline:" if ($realcnt != 0);
|
$here .= "FILE: $realfile:$realline:" if ($realcnt != 0);
|
||||||
|
|
||||||
my $hereline = "$here\n$rawline\n";
|
my $hereline = "$here\n$rawline\n";
|
||||||
my $herecurr = "$here\n$rawline\n";
|
my $herecurr = "$here\n$rawline\n";
|
||||||
my $hereprev = "$here\n$prevrawline\n$rawline\n";
|
my $hereprev = "$here\n$prevrawline\n$rawline\n";
|
||||||
|
|
||||||
|
if ($shorttext != AFTER_SHORTTEXT) {
|
||||||
|
if ($shorttext == IN_SHORTTEXT) {
|
||||||
|
if ($line=~/^---/ || $line=~/^diff.*/) {
|
||||||
|
$shorttext = AFTER_SHORTTEXT;
|
||||||
|
} elsif (length($line) > (SHORTTEXT_LIMIT +
|
||||||
|
$shorttext_exspc)
|
||||||
|
&& $line !~ /^:([0-7]{6}\s){2}
|
||||||
|
([[:xdigit:]]+\.*
|
||||||
|
\s){2}\w+\s\w+/xms) {
|
||||||
|
WARN("LONG_COMMIT_TEXT",
|
||||||
|
"commit text line over " .
|
||||||
|
SHORTTEXT_LIMIT .
|
||||||
|
" characters\n" . $herecurr);
|
||||||
|
}
|
||||||
|
} elsif ($line=~/^Subject: \[[^\]]*\] (.*)/) {
|
||||||
|
$shorttext = IN_SHORTTEXT;
|
||||||
|
if (length($1) > SHORTTEXT_LIMIT) {
|
||||||
|
WARN("LONG_SUMMARY_LINE",
|
||||||
|
"summary line over " .
|
||||||
|
SHORTTEXT_LIMIT .
|
||||||
|
" characters\n" . $herecurr);
|
||||||
|
}
|
||||||
|
} elsif ($line=~/^ (.*)/) {
|
||||||
|
$shorttext = IN_SHORTTEXT;
|
||||||
|
$shorttext_exspc = 4;
|
||||||
|
if (length($1) > SHORTTEXT_LIMIT) {
|
||||||
|
WARN("LONG_SUMMARY_LINE",
|
||||||
|
"summary line over " .
|
||||||
|
SHORTTEXT_LIMIT .
|
||||||
|
" characters\n" . $herecurr);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
$cnt_lines++ if ($realcnt != 0);
|
$cnt_lines++ if ($realcnt != 0);
|
||||||
|
|
||||||
# Check if the commit log has what seems like a diff which can confuse patch
|
# Check if the commit log has what seems like a diff which can confuse patch
|
||||||
|
|
Loading…
Add table
Reference in a new issue