Re: [PATCH 2/2] checkpatch: warn when Reported-by: is not followed by Link:

From: Joe Perches
Date: Thu Dec 08 2022 - 15:22:07 EST


On Thu, 2022-12-08 at 20:32 +0100, Kai Wasserbäch wrote:
> Encourage patch authors to link to reports by issuing a warning, if
> a Reported-by: is not accompanied by a link to the report. Those links
> are often extremely useful for any code archaeologist that wants to know
> more about the backstory of a change than the commit message provides.
> That includes maintainers higher up in the patch-flow hierarchy, which
> is why Linus asks developers to add such links [1, 2, 3]. To quote [1]:
>
> > Again, the commit has a link to the patch *submission*, which is
> > almost entirely useless. There's no link to the actual problem the
> > patch fixes.
> >
> > [...]
> >
> > Put another way: I can see that
> >
> > Reported-by: Zhangfei Gao <zhangfei.gao@xxxxxxxxxxx>
> >
> > in the commit, but I don't have a clue what the actual report was, and
> > there really isn't enough information in the commit itself, except for
> > a fairly handwavy "Device drivers might, for instance, still need to
> > flush operations.."
> >
> > I don't want to know what device drivers _might_ do. I would want to
> > have an actual pointer to what they do and where.
>
> Another reason why these links are wanted: the ongoing regression
> tracking efforts can only scale with them, as they allow the regression
> tracking bot 'regzbot' to automatically connect tracked reports with
> patches that are posted or committed to fix tracked regressions.
[]
> diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
[]
> @@ -3144,6 +3144,20 @@ sub process {
> "Co-developed-by and Signed-off-by: name/email do not match \n" . "$here\n" . $rawline . "\n" .$rawlines[$linenr]);

I believe this use of '"$here\n" . $rawline . "\n"' to be a defect.
I think this should just use $herecurr

And the unnecessary space before a newline is an abomination ;)

"Co-developed-by and Signed-off-by: name/email do not match\n" . $herecurr . $rawlines[$linenr]);

> +
> + # check if Reported-by: is followed by a Link:
> + if ($sign_off =~ /^reported-by:$/i) {
> + if (!defined $lines[$linenr]) {
> + WARN("BAD_REPORTED_BY_LINK",
> + "Reported-by: should be immediately followed by Link: to the report\n" . "$here\n" . $rawline);
> + } elsif ($rawlines[$linenr] !~ /^\s*link:\s*(.*)/i) {
> + WARN("BAD_REPORTED_BY_LINK",
> + "Reported-by: should be immediately followed by Link: to the report\n" . "$here\n" . $rawline . "\n" .$rawlines[$linenr]);
> + } elsif ($lines[$linenr] !~ /https?:\/\//i) {
> + WARN("BAD_REPORTED_BY_LINK",
> + "Link: following Reported-by: should contain an URL\n" . "$here\n" . $rawline . "\n" .$rawlines[$linenr]);

Please use a space before and after a string concatenation '.'

English generally uses "a URL" and not "an URL"
https://www.techtarget.com/whatis/feature/Which-is-correct-a-URL-or-an-URL

Also the actual link line should likely be from lore

So maybe:
} elsif ($lines[$linenr] !~ m{https?://lore.kernel.org/.+}i) {
WARN("BAD_REPORTED_BY_LINK",
"Link: following Reported-by: should use a lore.kernel.org URL\n" . $herecurr . $rawlines[$linenr]);

etc...