Skip to contentSkip to conversation

checkpatch: Exempt long URLs

PATCH Applied Eric Blake 3 participants 4 messages Feb 22, 2018 – Mar 7, 2018 Checkpatch

lore
Share & tools
lore

Eric Blake

author
#0 lore raw

PATCH 1/1 checkpatch: Exempt long URLs

Sometimes, we want to refer to really long URLs, but checkpatch balks, and we have to manually bypass the check. URL shorterners may be nice at reducing long links, but it's hard to guarantee the shortened link will live as long as the real target, and it is also nice to see the original target without having to load the shortened URL through a browser. So exempt a line containing only a URL from the long-line syntax check.

---
 scripts/checkpatch.pl | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
scripts/checkpatch.pl +2 -1
index 1b4b812e28f..0d3f753c665 100755
@@ -1447,9 +1447,10 @@ sub process {
 # check we are in a valid source file if not then ignore this hunk
 		next if ($realfile !~ /$SrcFile/);
 
-#90 column limit
+#90 column limit; exempt URLs, if no other words on line
 		if ($line =~ /^\+/ &&
 		    !($line =~ /^\+\s*"[^"]*"\s*(?:\s*|,|\)\s*;)\s*$/) &&
+		    !($rawline =~ /^[^[:alnum:]]*https?:\S*$/) &&
 		    $length > 80)
 		{
 			if ($length > 90) {
Signature · 1 line
2.14.3
author
#1 lore raw
Quoted 2 lines · Eric Blake

Sometimes, we want to refer to really long URLs, but checkpatch balks, and we have to manually bypass the check. URL shorterners

s/shorterners/shorteners/

(Is it bad when I spell-check my own patches?)

Quoted 9 lines

may be nice at reducing long links, but it's hard to guarantee the shortened link will live as long as the real target, and it is also nice to see the original target without having to load the shortened URL through a browser. So exempt a line containing only a URL from the long-line syntax check.

---

Signature · 3 lines
Eric Blake, Principal Software Engineer
Red Hat, Inc.           +1-919-301-3266
Virtualization:  qemu.org | libvirt.org
Reviewed-by on v1 1/1
#2 lore raw
In reply to Eric Blake
Quoted 8 lines · Eric Blake

Sometimes, we want to refer to really long URLs, but checkpatch balks, and we have to manually bypass the check. URL shorterners may be nice at reducing long links, but it's hard to guarantee the shortened link will live as long as the real target, and it is also nice to see the original target without having to load the shortened URL through a browser. So exempt a line containing only a URL from the long-line syntax check.

Quoted 5 lines
---
 scripts/checkpatch.pl | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
#3 lore raw
In reply to Eric Blake
Quoted 21 lines · Eric Blake

Sometimes, we want to refer to really long URLs, but checkpatch balks, and we have to manually bypass the check. URL shorterners may be nice at reducing long links, but it's hard to guarantee the shortened link will live as long as the real target, and it is also nice to see the original target without having to load the shortened URL through a browser. So exempt a line containing only a URL from the long-line syntax check.

---
 scripts/checkpatch.pl | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
scripts/checkpatch.pl +0 -0
index 1b4b812e28f..0d3f753c665 100755
@@ -1447,9 +1447,10 @@ sub process {
 # check we are in a valid source file if not then ignore this hunk

scripts/checkpatch.pl sub process { · line 1456

Quoted 10 lines
scripts/checkpatch.pl +2 -1
 		next if ($realfile !~ /$SrcFile/);
 
-#90 column limit
+#90 column limit; exempt URLs, if no other words on line
 		if ($line =~ /^\+/ &&
 		    !($line =~ /^\+\s*"[^"]*"\s*(?:\s*|,|\)\s*;)\s*$/) &&
+		    !($rawline =~ /^[^[:alnum:]]*https?:\S*$/) &&
 		    $length > 80)
 		{
 			if ($length > 90) {

Queued, thanks.

Paolo