Skip to contentSkip to conversation

checkpatch: allow URL >80 chars

PATCH In review Andreas Brauchli 2 participants 3 messages Nov 21, 2017 – Nov 22, 2017 Checkpatch

lore
Share & tools
lore
#0 lore raw

PATCH v3 1/1 checkpatch: allow URL >80 chars

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 only non-word (\W) and underscore characters are allowed beside the URL (e.g. ' /* _https://..._ */')

As per RFC3986 [1], the URL format allows for alphanum, +, - and . characters in the scheme before the separator :// as long as it starts with a letter (e.g. https, git, f.-+).

Recognition of URIs without more context information is prone to false positives and thus currently left out of the heuristics.

$rawline is used in the check as comments are removed from $line.

[1] https://tools.ietf.org/html/rfc3986#section-3.1

---
 scripts/checkpatch.pl | 4 ++++
 1 file changed, 4 insertions(+)
scripts/checkpatch.pl +4 -0
index 95cda3ecc66b..ac223921f7e0 100755
@@ -2906,6 +2906,10 @@ sub process {
 				 $line =~ /^\+\s*(?:\w+)?\s*DEFINE_PER_CPU/) {
 				$msg_type = "";
 
+			# URL (w/ non-word char padding e.g. " /* */")
+			} elsif ($rawline =~ /^\+[\W_]*?\b([a-z][\w\.\+\-]*:\/\/\S+[^\s\)\]\.">;,])[\W_]*$/i) {
+				$msg_type = "";
+
 			# Otherwise set the alternate message types
 
 			# a comment starts before $max_line_length
Signature · 1 line
2.14.1
maintainer
#1 lore raw
Quoted 8 lines · Andreas Brauchli

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 only non-word (\W) and underscore characters are allowed beside the URL (e.g. ' /* _https://..._ */')

Perhaps you are overthinking it.

If a line contains a URL, and it's > $max_line_length, then it's probably OK not to warn about it as as overly long line.

I suggest:

---
 scripts/checkpatch.pl | 5 +++++
 1 file changed, 5 insertions(+)
scripts/checkpatch.pl +5 -0
index 95cda3ecc66b..0e42e5ebe2f0 100755
@@ -2875,6 +2875,7 @@ sub process {
 #	logging functions like pr_info that end in a string
 #	lines with a single string
 #	#defines that are a single string
+#	lines with an RFC3986 like URL
 #
 # There are 3 different line length message types:
 # LONG_LINE_COMMENT	a comment starts before but extends beyond $max_line_length
@@ -2906,6 +2907,10 @@ sub process {
 				 $line =~ /^\+\s*(?:\w+)?\s*DEFINE_PER_CPU/) {
 				$msg_type = "";
 
+			# URL ($rawline is used if the URL is in a comment)
+			} elsif ($rawline =~ /^\+.*\b[a-z][\w\.\+\-]*:\/\/\S+/i) {
+				$msg_type = "";
+
 			# Otherwise set the alternate message types
 
 			# a comment starts before $max_line_length
#2 lore raw
Quoted 10 lines · Joe Perches
Quoted 8 lines · Andreas Brauchli

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 only non-word (\W) and underscore characters are allowed beside the URL (e.g. ' /* _https://..._ */')

Quoted 5 lines

Perhaps you are overthinking it.

If a line contains a URL, and it's > $max_line_length, then it's probably OK not to warn about it as as overly long line.

Yes, I see. I was going for a different solution: if the URL is already over the allowable length, no other content parts would be allowed on the same line.

Quoted 20 lines

I suggest:

---
 scripts/checkpatch.pl | 5 +++++
 1 file changed, 5 insertions(+)
scripts/checkpatch.pl +1 -0
index 95cda3ecc66b..0e42e5ebe2f0 100755
@@ -2875,6 +2875,7 @@ sub process {
 #	logging functions like pr_info that end in a string
 #	lines with a single string
 #	#defines that are a single string
+#	lines with an RFC3986 like URL
 #
 # There are 3 different line length message types:
 # LONG_LINE_COMMENT	a comment starts before but extends beyond $max_line_length

scripts/checkpatch.pl sub process { · line 2916

Quoted 10 lines
scripts/checkpatch.pl +4 -0
@@ -2906,6 +2907,10 @@ sub process {
 				 $line =~ /^\+\s*(?:\w+)?\s*DEFINE_PER_CPU/) {
 				$msg_type = "";
 
+			# URL ($rawline is used if the URL is in a comment)
+			} elsif ($rawline =~ /^\+.*\b[a-z][\w\.\+\-
+				$msg_type = "";
+
 			# Otherwise set the alternate message types
 
 			# a comment starts before $max_line_length

Thanks, I'll resend this as v4

Thanks,
Andreas