lkml.org 
[lkml]   [2022]   [Dec]   [18]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH 2/3] checkpatch: warn when Reported-by: is not followed by Link:
On 15.12.22 19:00, Joe Perches wrote:
> On Thu, 2022-12-15 at 15:43 +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.
>
> Please also expand Documentation/ as appropriate to encourage this too.

Well, I already updated it a few moths ago, but yeah, will revisit the
docs and make it even clearer if needed (I assume that's the case).

>> diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
> []
>> @@ -3155,6 +3155,20 @@ sub process {
>> "Co-developed-by and Signed-off-by: name/email do not match \n" . "$here\n" . $rawline . "\n" .$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" . $herecurr . $rawlines[$linenr] . "\n");
>> + } elsif ($rawlines[$linenr] !~ /^\s*link:\s*(.*)/i) {
>
> This capture group isn't necessary and does not guarantee there is
> an actual link. Also this is allowing spaces before "Link:" when
> the reported-by test above does not allow spaces. Please be
> consistent. My preference would be to not allow spaces.

Good idea. FWIW, the section patch 3 changes has a space here as well:
```
> } elsif ($rawlines[$linenr] !~ /^\s*signed-off-by:\s*(.*)/i) {
```
Hence I guess I'll remove it as well, unless you for some reason tell me
that's a bad idea.

>> + WARN("BAD_REPORTED_BY_LINK",
>> + "Reported-by: should be immediately followed by Link: to the report\n" . $herecurr . $rawlines[$linenr] . "\n");
>> + } elsif ($lines[$linenr] !~ /https?:\/\//i) {
>
> To make reading the match pattern easier, prefer m{} when the expected
> content uses / instead of using / as a delimiter.

Also a good idea. That being said:

I think I'll drop this check, as your comment made me think: why should
we check for "https?://" here at all? If we want to check that a "Link:"
is followed by a URI, then we should do that all the time, not just in
this single case.

Or am I missing something?

>> + WARN("BAD_REPORTED_BY_LINK",
>> + "Link: following Reported-by: should contain a URL\n" . $herecurr . $rawlines[$linenr] . "\n");
>> + }
>> + }
>> }
>>
>> # Check Fixes: styles is correct

Ciao, Thorsten

\
 
 \ /
  Last update: 2022-12-18 15:54    [W:0.095 / U:0.016 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site