checkpatch: Make the 80-character limit a --strict check only
RFC PATCH 1/1 checkpatch: Make the 80-character limit a --strict check only
The 80-character limit is not a hard-and-fast rule, nor should it be applied blindly by people running checkpatch and fixing its warnings. Sometimes it's better to violate the 80-character "limit" in the name of readability, and when it isn't, it's often better to refactor into a function or otherwise restructure the code rather than just finding increasingly awkward places to break lines.
Thus, change checkpatch's LONG_LINE warning to a --strict CHK instead. Anyone wanting to use checkpatch to check for this can easily enough enable --strict or turn on LONG_LINE explicitly, but it shouldn't be part of the default warnings.
---
scripts/checkpatch.pl | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
scripts/checkpatch.pl +2 -2
@@ -2017,8 +2017,8 @@ sub process { $line =~ /^\+\s*"[^"]*"\s*(?:\s*|,|\)\s*;)\s*$/) && $length > $max_line_length) { - WARN("LONG_LINE", - "line over $max_line_length characters\n" . $herecurr); + CHK("LONG_LINE", + "line over $max_line_length characters\n" . $herecurr); } # Check for user-visible strings broken across lines, which breaks the ability
Signature · 1 line
1.8.4.rc3
Joe Perches
maintainerQuoted 11 lines · Josh Triplett
The 80-character limit is not a hard-and-fast rule, nor should it be applied blindly by people running checkpatch and fixing its warnings. Sometimes it's better to violate the 80-character "limit" in the name of readability, and when it isn't, it's often better to refactor into a function or otherwise restructure the code rather than just finding increasingly awkward places to break lines.
Thus, change checkpatch's
LONG_LINEwarning to a --strict CHK instead. Anyone wanting to use checkpatch to check for this can easily enough enable --strict or turn onLONG_LINEexplicitly, but it shouldn't be part of the default warnings.
I don't agree with this.
CodingStyle says:
----------------------
The limit on the length of lines is 80 columns and this is a strongly preferred limit.
----------------------
People should be encouraged to use 80 column lines and as well should learn to ignore messages they don't agree with.
If people are using checkpatch prior to any scripted git am, then just as easily they could add --ignore=LONG_LINE.
Quoted 13 lines · Joe Perches
Quoted 11 lines · Josh Triplett
The 80-character limit is not a hard-and-fast rule, nor should it be applied blindly by people running checkpatch and fixing its warnings. Sometimes it's better to violate the 80-character "limit" in the name of readability, and when it isn't, it's often better to refactor into a function or otherwise restructure the code rather than just finding increasingly awkward places to break lines.
Thus, change checkpatch's
LONG_LINEwarning to a --strict CHK instead. Anyone wanting to use checkpatch to check for this can easily enough enable --strict or turn onLONG_LINEexplicitly, but it shouldn't be part of the default warnings.
Quoted 7 lines
I don't agree with this.
CodingStyle says:
----------------------
The limit on the length of lines is 80 columns and this is a strongly preferred limit.
----------------------
Which is the subject of much controversy and extensive discussion, and the consensus on the list (including by many maintainers) frequently differs from that.
Quoted 2 lines
People should be encouraged to use 80 column lines and as well should learn to ignore messages they don't agree with.
I've seen far more examples of the 80-column limit making code less readable rather than more. It's only really helpful when it forces code restructuring, *not* when it just forces an arbitrary line break.
Quoted 2 lines
If people are using checkpatch prior to any scripted git am, then just as easily they could add --ignore=LONG_LINE.
Which random folks running checkpatch on staging drivers and trying to help don't necessarily know to do. The defaults should cater to the primary use case, and the 80-column limit is not something to apply blindly. It falls in the same category as some of the warnings the kernel emits with W=2 or so: sometimes helpful, often noise.
- Josh Triplett
Joe Perches
maintainerQuoted 22 lines · Josh Triplett
Quoted 13 lines · Joe Perches
Quoted 11 lines · Josh Triplett
The 80-character limit is not a hard-and-fast rule, nor should it be applied blindly by people running checkpatch and fixing its warnings. Sometimes it's better to violate the 80-character "limit" in the name of readability, and when it isn't, it's often better to refactor into a function or otherwise restructure the code rather than just finding increasingly awkward places to break lines.
Thus, change checkpatch's
LONG_LINEwarning to a --strict CHK instead. Anyone wanting to use checkpatch to check for this can easily enough enable --strict or turn onLONG_LINEexplicitly, but it shouldn't be part of the default warnings.Quoted 7 lines
I don't agree with this.
CodingStyle says:
----------------------
The limit on the length of lines is 80 columns and this is a strongly preferred limit.
----------------------
Quoted 3 lines
Which is the subject of much controversy and extensive discussion, and the consensus on the list (including by many maintainers) frequently differs from that.
Been there, had that discussion.
https://lkml.org/lkml/2009/12/18/3
I'm not applying/acking this.
Quoted 23 lines · Joe Perches
Quoted 22 lines · Josh Triplett
Quoted 20 lines · Joe Perches
Quoted 11 lines · Josh Triplett
The 80-character limit is not a hard-and-fast rule, nor should it be applied blindly by people running checkpatch and fixing its warnings. Sometimes it's better to violate the 80-character "limit" in the name of readability, and when it isn't, it's often better to refactor into a function or otherwise restructure the code rather than just finding increasingly awkward places to break lines.
Thus, change checkpatch's
LONG_LINEwarning to a --strict CHK instead. Anyone wanting to use checkpatch to check for this can easily enough enable --strict or turn onLONG_LINEexplicitly, but it shouldn't be part of the default warnings.I don't agree with this.
CodingStyle says:
----------------------
The limit on the length of lines is 80 columns and this is a strongly preferred limit.
----------------------
Quoted 6 lines
Quoted 3 lines
Which is the subject of much controversy and extensive discussion, and the consensus on the list (including by many maintainers) frequently differs from that.
Been there, had that discussion.
https://lkml.org/lkml/2009/12/18/3
I see many positive responses in that thread, from Linus and others, and very little negativity (mostly quibbles about implementation, not about the overall proposal). What was the problem?
In particular:
Quoted 2 lines
I'll happily remove the checkpatch.pl limit entirely, and ask people to try to use common sense, though.
Between that and the positive responses in this thread, I'd love to see your proposed patch revived.
- Josh Triplett
Quoted 3 lines · Josh Triplett
I've seen far more examples of the 80-column limit making code less readable rather than more. It's only really helpful when it forces code restructuring, *not* when it just forces an arbitrary line break.
So teach that piece of crap to complain about fucked-in-head line breaks like
ret_val = leaf_shift_left(tb, tb-> lnum [0], tb-> lbytes - 1);
in addition to obscenely long lines (and yes, it is a real-world example).
The one and only point of such tools is to help locating the crappy code. And that's the only sane criterion for evaluating new "stylistic rules" - does that particular heuristic catch enough shitty places or not?
_Anything_ can be obfuscated to the point where warnings are not produced anymore...
Joe Perches
maintainerQuoted 16 lines · Al Viro
Quoted 3 lines · Josh Triplett
I've seen far more examples of the 80-column limit making code less readable rather than more. It's only really helpful when it forces code restructuring, *not* when it just forces an arbitrary line break.
So teach that piece of crap to complain about fucked-in-head line breaks like
ret_val = leaf_shift_left(tb, tb-> lnum [0], tb-> lbytes - 1);
Quoted 1 line
in addition to obscenely long lines (and yes, it is a real-world example).
Yup, that's pretty ugly.
It was autogenerated and introduced when Linus
rather arbitrarily lindented the reiserfs code.
btw: I think lindent should be removed from scripts/
http://lkml.org/lkml/2013/2/11/390
I believe reiserfs was originally set to a 132
column width maximum.
commit bd4c625c061c2a38568d0add3478f59172455159
Author: Linus Torvalds <[email protected]> Date: Tue Jul 12 20:21:28 2005 -0700
reiserfs: run scripts/Lindent on reiserfs code
This was a pure indentation change, using:
scripts/Lindent fs/reiserfs/*.c include/linux/reiserfs_*.h
Joe Perches
maintainerQuoted 7 lines · Joe Perches
Quoted 6 lines · Al Viro
Quoted 3 lines · Josh Triplett
I've seen far more examples of the 80-column limit making code less readable rather than more. It's only really helpful when it forces code restructuring, *not* when it just forces an arbitrary line break.
Quoted 11 lines
Quoted 11 lines
So teach that piece of crap to complain about fucked-in-head line breaks like
ret_val = leaf_shift_left(tb, tb-> lnum [0], tb-> lbytes - 1);in addition to obscenely long lines (and yes, it is a real-world example).
btw: checkpatch does suggest refactoring when there are 6+ indent tabs with an if/while/for/do/switch statement. so it already does bleat around there.
Quoted 7 lines · Josh Triplett
The 80-character limit is not a hard-and-fast rule, nor should it be applied blindly by people running checkpatch and fixing its warnings. Sometimes it's better to violate the 80-character "limit" in the name of readability, and when it isn't, it's often better to refactor into a function or otherwise restructure the code rather than just finding increasingly awkward places to break lines.
Quoted 6 lines
Thus, change checkpatch's
LONG_LINEwarning to a --strict CHK instead. Anyone wanting to use checkpatch to check for this can easily enough enable --strict or turn onLONG_LINEexplicitly, but it shouldn't be part of the default warnings.Signed-off-by Josh Triplett <[email protected]>
As I'm not a huge fan of the 80-character limit,
Quoted 28 lines
---
scripts/checkpatch.pl | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)scripts/checkpatch.pl +2
-3@@ -2017,8 +2017,8 @@ sub process { $line =~ /^\+\s*"[^"]*"\s*(?:\s*|,|\)\s*;)\s*$/) && $length > $max_line_length) { - WARN("LONG_LINE", - "line over $max_line_length characters\n" . $herecurr); + CHK("LONG_LINE", + "line over $max_line_length characters\n" . $herecurr); } # Check for user-visible strings broken across lines, which breaks the ability --1.8.4.rc3
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Signature · 2 lines
Thanks, //richard
Quoted 6 lines · Josh Triplett
The 80-character limit is not a hard-and-fast rule, nor should it be applied blindly by people running checkpatch and fixing its warnings. Sometimes it's better to violate the 80-character "limit" in the name of readability, and when it isn't, it's often better to refactor into a function or otherwise restructure the code rather than just finding increasingly awkward places to break lines.
Yes please!
-Andi
Signature · 1 line
[email protected] -- Speaking for myself only
Quoted 7 lines · Josh Triplett
The 80-character limit is not a hard-and-fast rule, nor should it be applied blindly by people running checkpatch and fixing its warnings. Sometimes it's better to violate the 80-character "limit" in the name of readability, and when it isn't, it's often better to refactor into a function or otherwise restructure the code rather than just finding increasingly awkward places to break lines.
Quoted 6 lines
Thus, change checkpatch's
LONG_LINEwarning to a --strict CHK instead. Anyone wanting to use checkpatch to check for this can easily enough enable --strict or turn onLONG_LINEexplicitly, but it shouldn't be part of the default warnings.Signed-off-by Josh Triplett <[email protected]>