Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 09096f18 authored by qctecmdr's avatar qctecmdr Committed by Gerrit - the friendly Code Review server
Browse files

Merge "checkpatch: warn on long summary, commit text lines"

parents d3865300 65cfc434
Loading
Loading
Loading
Loading
+42 −2
Original line number Diff line number Diff line
@@ -15,6 +15,11 @@ use Cwd 'abs_path';
use Term::ANSIColor qw(:constants);
use Encode qw(decode encode);

use constant BEFORE_SHORTTEXT => 0;
use constant IN_SHORTTEXT => 1;
use constant AFTER_SHORTTEXT => 2;
use constant SHORTTEXT_LIMIT => 75;

my $P = $0;
my $D = dirname(abs_path($P));

@@ -2333,6 +2338,8 @@ sub process {
	my $setup_docs = 0;

	my $camelcase_file_seeded = 0;
	my $shorttext = BEFORE_SHORTTEXT;
	my $shorttext_exspc = 0;

	my $checklicenseline = 1;

@@ -2551,13 +2558,46 @@ sub process {

			next;
		}

		$here .= "FILE: $realfile:$realline:" if ($realcnt != 0);

		my $hereline = "$here\n$rawline\n";
		my $herecurr = "$here\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);

# Verify the existence of a commit log if appropriate
@@ -5576,7 +5616,7 @@ sub process {
		}

# dsb is too ARMish, and should usually be mb.
		if ($line =~ /\bdsb\b/) {
		if ($line =~ /[^-_>*\.]\bdsb\b[^-_\.;]/) {
			WARN("ARM_BARRIER",
			     "Use of dsb is discouranged: prefer mb.\n" .
			     $herecurr);