[Qemu-devel] [PATCH v3] checkpatch: Flag suspicious attribution lines

Eric Blake posted 1 patch 5 years, 2 months ago
Test docker-mingw@fedora passed
Test asan failed
Test checkpatch passed
Test docker-clang@ubuntu passed
Patches applied successfully (tree, apply log)
git fetch https://github.com/patchew-project/qemu tags/patchew/20190205022502.11654-1-eblake@redhat.com
scripts/checkpatch.pl | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
[Qemu-devel] [PATCH v3] checkpatch: Flag suspicious attribution lines
Posted by Eric Blake 5 years, 2 months ago
Flag commit attribution tags that are unusual (often because they
were a typo), but only as a warning (because sometimes a humorous
or otherwise useful tag is intentionally supplied).

This picks the 6 most popular tags, each with 700 or more uses (well,
S-o-b was already checked for case-sensitivity and typos, leaving
only 5 new tags being checked), as determined by:
$ git log | sed -n 's/^ *\([A-Za-z-]*-[bB][yY]:\).*/\1/p' | \
  sort | uniq -c | sort -k1,1n | tail

Most of the rejected lines were unusual case (48 Reviewed-By), or
obvious typos (among others, we've had 4 cases of someone being
burnt, based on Singed-off-by; and 2 cases of list-reading via an
e-reader, based on eviewed-by); there are also lines forgetting a
space after the ':') or otherwise tongue-in-check (my favorite:
3 Approximately-suggested-by). A few lines not whitelisted here
may be legitimate, but as they are orders of magnitude rarer, it
is therefore not worth worrying about (7 Requested-by,
3 Co-authored-by, 1 Inspired-by, etc.).

Signed-off-by: Eric Blake <eblake@redhat.com>

---
v3: also flag *-By [Philippe]
v2: fix regex
---
 scripts/checkpatch.pl | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
index 88682cb0a9f..e1aef5ba897 100755
--- a/scripts/checkpatch.pl
+++ b/scripts/checkpatch.pl
@@ -1456,7 +1456,7 @@ sub process {
 		    ERROR("Author email address is mangled by the mailing list\n" . $herecurr);
 		}

-#check the patch for a signoff:
+#check the patch for a signoff, and that other attribution lines are typical:
 		if ($line =~ /^\s*signed-off-by:/i) {
 			# This is a signoff, if ugly, so do not double report.
 			$signoff++;
@@ -1470,6 +1470,10 @@ sub process {
 				ERROR("space required after Signed-off-by:\n" .
 					$herecurr);
 			}
+		} elsif($line =~ /^\s*([a-z-]*)-by:/i &&
+			($1 !~ /(Suggest|Report|Test|Ack|Review)ed/ ||
+			 $line !~ /^\s*[A-Za-z-]*-by:\s/)) {
+		    WARN("suspicious attribution tag:\n" . $herecurr);
 		}

 # Check if MAINTAINERS is being updated.  If so, there's probably no need to
-- 
2.20.1


Re: [Qemu-devel] [PATCH v3] checkpatch: Flag suspicious attribution lines
Posted by Eric Blake 5 years, 2 months ago
On 2/4/19 8:25 PM, Eric Blake wrote:
> Flag commit attribution tags that are unusual (often because they
> were a typo), but only as a warning (because sometimes a humorous
> or otherwise useful tag is intentionally supplied).
> 
> This picks the 6 most popular tags, each with 700 or more uses (well,
> S-o-b was already checked for case-sensitivity and typos, leaving
> only 5 new tags being checked), as determined by:
> $ git log | sed -n 's/^ *\([A-Za-z-]*-[bB][yY]:\).*/\1/p' | \
>   sort | uniq -c | sort -k1,1n | tail

[-_][bB][yY] finds an additional:

      2 Reviewed_by:

Should I try to flag those as well, in v4 (note - the current
Signed-off-by tests do not flag Signed_off_by as invalid, so the patch
does get a bit bigger if we want to catch it)

-- 
Eric Blake, Principal Software Engineer
Red Hat, Inc.           +1-919-301-3226
Virtualization:  qemu.org | libvirt.org