mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] scripts/checkpatch: Fix multiple Reported-by: false positive warning
@ 2024-10-09 10:23 Advait Dhamorikar
  2024-10-22  2:21 ` Advait Dhamorikar
  0 siblings, 1 reply; 2+ messages in thread
From: Advait Dhamorikar @ 2024-10-09 10:23 UTC (permalink / raw)
  To: Andy Whitcroft, Joe Perches, Dwaipayan Ray, Lukas Bulwahn
  Cc: linux-kernel, skhan, anupnewsmail, Advait Dhamorikar

If multiple Reported-by: tags are used, the
checkpatch script throws a false positive warning
even when there is a Closes tag following the two
tags. This fix checks if the closes tag is present
after multiple Reported-by tags.

Here is an example of the same:
> WARNING: Reported-by: should be immediately followed by Closes: with a
> URL to the report
> #10:
> Reported-by: Kernel test bot <ppppqqqq@ymail.com>
> Reported-by: Some Person <xxxyyy@gmail.com>

> total: 0 errors, 1 warnings, 0 checks, 8 lines checked

Signed-off-by: Advait Dhamorikar <advaitdhamorikar@gmail.com>
---
 scripts/checkpatch.pl | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)

diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
index 4427572b2477..c74519f02180 100755
--- a/scripts/checkpatch.pl
+++ b/scripts/checkpatch.pl
@@ -3188,10 +3188,13 @@ sub process {
 			if ($sign_off =~ /^reported(?:|-and-tested)-by:$/i) {
 				if (!defined $lines[$linenr]) {
 					WARN("BAD_REPORTED_BY_LINK",
-					     "Reported-by: should be immediately followed by Closes: with a URL to the report\n" . $herecurr . "\n");
-				} elsif ($rawlines[$linenr] !~ /^closes:\s*/i) {
+						"Reported-by: should be immediately followed by Closes: with a URL to the report\n" . $herecurr . "\n");
+				} elsif ($lines[$linenr] =~ /^reported(?:|-and-tested)-by:/i && $lines[$linenr + 1] =~ /^reported(?:|-and-tested)-by:/i) {
+       				 # Do nothing if the next line is another Reported-by:
+                }
+				elsif ($lines[$linenr]  =~ /^reported(?:|-and-tested)-by:/i && $lines[$linenr + 1] !~ /^closes:\s*/i) {
 					WARN("BAD_REPORTED_BY_LINK",
-					     "Reported-by: should be immediately followed by Closes: with a URL to the report\n" . $herecurr . $rawlines[$linenr] . "\n");
+						"Reported-by: should be immediately followed by Closes: with a URL to the report\n" . "#" . ($linenr + 1) . ":" . "\n" . $rawlines[$linenr] . "\n");
 				}
 			}
 		}
-- 
2.34.1


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH] scripts/checkpatch: Fix multiple Reported-by: false positive warning
  2024-10-09 10:23 [PATCH] scripts/checkpatch: Fix multiple Reported-by: false positive warning Advait Dhamorikar
@ 2024-10-22  2:21 ` Advait Dhamorikar
  0 siblings, 0 replies; 2+ messages in thread
From: Advait Dhamorikar @ 2024-10-22  2:21 UTC (permalink / raw)
  To: Andy Whitcroft, Joe Perches, Dwaipayan Ray, Lukas Bulwahn
  Cc: linux-kernel, skhan, anupnewsmail

Hello all,

I would like to kindly ping for a review on the following patch.
I would greatly appreciate your feedback.

Thanks for your time and consideration.

Kind regards,
Advait

On Wed, 9 Oct 2024 at 15:53, Advait Dhamorikar
<advaitdhamorikar@gmail.com> wrote:
>
> If multiple Reported-by: tags are used, the
> checkpatch script throws a false positive warning
> even when there is a Closes tag following the two
> tags. This fix checks if the closes tag is present
> after multiple Reported-by tags.
>
> Here is an example of the same:
> > WARNING: Reported-by: should be immediately followed by Closes: with a
> > URL to the report
> > #10:
> > Reported-by: Kernel test bot <ppppqqqq@ymail.com>
> > Reported-by: Some Person <xxxyyy@gmail.com>
>
> > total: 0 errors, 1 warnings, 0 checks, 8 lines checked
>
> Signed-off-by: Advait Dhamorikar <advaitdhamorikar@gmail.com>
> ---
>  scripts/checkpatch.pl | 9 ++++++---
>  1 file changed, 6 insertions(+), 3 deletions(-)
>
> diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
> index 4427572b2477..c74519f02180 100755
> --- a/scripts/checkpatch.pl
> +++ b/scripts/checkpatch.pl
> @@ -3188,10 +3188,13 @@ sub process {
>                         if ($sign_off =~ /^reported(?:|-and-tested)-by:$/i) {
>                                 if (!defined $lines[$linenr]) {
>                                         WARN("BAD_REPORTED_BY_LINK",
> -                                            "Reported-by: should be immediately followed by Closes: with a URL to the report\n" . $herecurr . "\n");
> -                               } elsif ($rawlines[$linenr] !~ /^closes:\s*/i) {
> +                                               "Reported-by: should be immediately followed by Closes: with a URL to the report\n" . $herecurr . "\n");
> +                               } elsif ($lines[$linenr] =~ /^reported(?:|-and-tested)-by:/i && $lines[$linenr + 1] =~ /^reported(?:|-and-tested)-by:/i) {
> +                                        # Do nothing if the next line is another Reported-by:
> +                }
> +                               elsif ($lines[$linenr]  =~ /^reported(?:|-and-tested)-by:/i && $lines[$linenr + 1] !~ /^closes:\s*/i) {
>                                         WARN("BAD_REPORTED_BY_LINK",
> -                                            "Reported-by: should be immediately followed by Closes: with a URL to the report\n" . $herecurr . $rawlines[$linenr] . "\n");
> +                                               "Reported-by: should be immediately followed by Closes: with a URL to the report\n" . "#" . ($linenr + 1) . ":" . "\n" . $rawlines[$linenr] . "\n");
>                                 }
>                         }
>                 }
> --
> 2.34.1
>

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2024-10-22  2:22 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-10-09 10:23 [PATCH] scripts/checkpatch: Fix multiple Reported-by: false positive warning Advait Dhamorikar
2024-10-22  2:21 ` Advait Dhamorikar

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®