* [PATCH] checkpatch: allow URL >80 chars
@ 2017-11-17 15:56 Andreas Brauchli
2017-11-18 5:21 ` Joe Perches
0 siblings, 1 reply; 4+ messages in thread
From: Andreas Brauchli @ 2017-11-17 15:56 UTC (permalink / raw)
To: Andy Whitcroft, Joe Perches; +Cc: linux-kernel
Allow URL to exceed the 80 char limit for improved interaction in
adaption to ongoing but undocumented practice.
$ git grep -E '://\S{77}.*' -- '*.[ch]'
The patch checks that the URL is indeed on its own line in that it
allows a maximal prefix of 4 characters to account for a URL after a
comment (e.g. ' // https://...')
The URL format allows for up to 5 protocol characters before the
separator :// (e.g. https, git, ...). Additionally, an URL starting
with a "domain.tld" or "subdomain.domain" pattern (e.g.
'www.kernel.org') is also accepted.
$rawline is used in the check as comments are removed from $line.
Signed-off-by: Andreas Brauchli <andreas.brauchli@sensirion.com>
---
scripts/checkpatch.pl | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
index 8b80bac055e4..aed447923354 100755
--- a/scripts/checkpatch.pl
+++ b/scripts/checkpatch.pl
@@ -2904,6 +2904,11 @@ sub process {
} elsif ($line =~ /^\+.*\bEFI_GUID\s*\(/) {
$msg_type = "";
+ # URL (w/ minimal padding e.g. "+ // ")
+ } elsif ($rawline =~ /^\+.*?\b((?:\w{1,5}:\/\/|\w+\.\w+)\S+).*$/ &&
+ length($rawline) - length($1) <= 5) {
+ $msg_type = "";
+
# Otherwise set the alternate message types
# a comment starts before $max_line_length
--
2.14.1
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH] checkpatch: allow URL >80 chars
2017-11-17 15:56 [PATCH] checkpatch: allow URL >80 chars Andreas Brauchli
@ 2017-11-18 5:21 ` Joe Perches
2017-11-18 10:07 ` Andreas Brauchli
0 siblings, 1 reply; 4+ messages in thread
From: Joe Perches @ 2017-11-18 5:21 UTC (permalink / raw)
To: Andreas Brauchli, Andy Whitcroft; +Cc: linux-kernel
On Fri, 2017-11-17 at 16:56 +0100, Andreas Brauchli wrote:
> Allow URL to exceed the 80 char limit for improved interaction in
> adaption to ongoing but undocumented practice.
>
> $ git grep -E '://\S{77}.*' -- '*.[ch]'
>
> The patch checks that the URL is indeed on its own line in that it
> allows a maximal prefix of 4 characters to account for a URL after a
> comment (e.g. ' // https://...')
>
> The URL format allows for up to 5 protocol characters before the
> separator :// (e.g. https, git, ...). Additionally, an URL starting
> with a "domain.tld" or "subdomain.domain" pattern (e.g.
> 'www.kernel.org') is also accepted.
>
> $rawline is used in the check as comments are removed from $line.
>
> Signed-off-by: Andreas Brauchli <andreas.brauchli@sensirion.com>
> ---
> scripts/checkpatch.pl | 5 +++++
> 1 file changed, 5 insertions(+)
>
> diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
> index 8b80bac055e4..aed447923354 100755
> --- a/scripts/checkpatch.pl
> +++ b/scripts/checkpatch.pl
> @@ -2904,6 +2904,11 @@ sub process {
> } elsif ($line =~ /^\+.*\bEFI_GUID\s*\(/) {
> $msg_type = "";
>
> + # URL (w/ minimal padding e.g. "+ // ")
> + } elsif ($rawline =~ /^\+.*?\b((?:\w{1,5}:\/\/|\w+\.\w+)\S+).*$/ &&
nack.
this matches member dereference lines like
foo.bar = baz;
and include lines like
#include <foo.h>
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] checkpatch: allow URL >80 chars
2017-11-18 5:21 ` Joe Perches
@ 2017-11-18 10:07 ` Andreas Brauchli
2017-11-18 14:39 ` Joe Perches
0 siblings, 1 reply; 4+ messages in thread
From: Andreas Brauchli @ 2017-11-18 10:07 UTC (permalink / raw)
To: Joe Perches, Andy Whitcroft; +Cc: linux-kernel
On Fre, 2017-11-17 at 21:21 -0800, Joe Perches wrote:
> On Fri, 2017-11-17 at 16:56 +0100, Andreas Brauchli wrote:
> > Allow URL to exceed the 80 char limit for improved interaction in
> > adaption to ongoing but undocumented practice.
> >
> > $ git grep -E '://\S{77}.*' -- '*.[ch]'
> >
> > The patch checks that the URL is indeed on its own line in that it
> > allows a maximal prefix of 4 characters to account for a URL after a
> > comment (e.g. ' // https://...')
> >
> > The URL format allows for up to 5 protocol characters before the
> > separator :// (e.g. https, git, ...). Additionally, an URL starting
> > with a "domain.tld" or "subdomain.domain" pattern (e.g.
> > 'www.kernel.org') is also accepted.
> >
> > $rawline is used in the check as comments are removed from $line.
> >
> > Signed-off-by: Andreas Brauchli <andreas.brauchli@sensirion.com>
> > ---
> > scripts/checkpatch.pl | 5 +++++
> > 1 file changed, 5 insertions(+)
> >
> > diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
> > index 8b80bac055e4..aed447923354 100755
> > --- a/scripts/checkpatch.pl
> > +++ b/scripts/checkpatch.pl
> > @@ -2904,6 +2904,11 @@ sub process {
> > } elsif ($line =~ /^\+.*\bEFI_GUID\s*\(/) {
> > $msg_type = "";
> >
> > + # URL (w/ minimal padding e.g. "+ // ")
> > + } elsif ($rawline =~ /^\+.*?\b((?:\w{1,5}:\/\/|\w+\.\w+)\S+).*$/ &&
>
> nack.
>
> this matches member dereference lines like
>
> foo.bar = baz;
>
> and include lines like
>
> #include <foo.h>
Agreed, there are even a few false positives (all member derefs).
Apologies for failing to catch those.
Is the patch acceptable if it only catches URL with protocol specifiers
foo:// ? That would catch most cases and doesn't show false positives:
$ git grep -E '://\S{75}.*' -- '*.[ch]'
Cheers,
Andreas
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] checkpatch: allow URL >80 chars
2017-11-18 10:07 ` Andreas Brauchli
@ 2017-11-18 14:39 ` Joe Perches
0 siblings, 0 replies; 4+ messages in thread
From: Joe Perches @ 2017-11-18 14:39 UTC (permalink / raw)
To: Andreas Brauchli, Andy Whitcroft; +Cc: linux-kernel
On Sat, 2017-11-18 at 11:07 +0100, Andreas Brauchli wrote:
> Is the patch acceptable if it only catches URL with protocol specifiers
> foo:// ? That would catch most cases and doesn't show false positives:
> $ git grep -E '://\S{75}.*' -- '*.[ch]'
Of course. but I suggest using a prefix like
\b[\w\.\+\-]+://
so the URL scheme is properly described.
It might be best if there was some generic mechanism
to identify possible URIs and not just URLs instead.
https://en.wikipedia.org/wiki/Uniform_Resource_Identifier
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2017-11-18 14:40 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-11-17 15:56 [PATCH] checkpatch: allow URL >80 chars Andreas Brauchli
2017-11-18 5:21 ` Joe Perches
2017-11-18 10:07 ` Andreas Brauchli
2017-11-18 14:39 ` Joe Perches
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox