mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Joe Perches <joe@perches.com>
To: Josh Triplett <josh@joshtriplett.org>
Cc: Andy Whitcroft <apw@canonical.com>,
	gregkh@linux-foundation.org, akpm@linux-foundation.org,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH] scripts/checkpatch.pl: Improve guidance for LONG_LINE
Date: Thu, 26 Jun 2014 03:09:05 -0700	[thread overview]
Message-ID: <1403777345.7977.36.camel@joe-AO725> (raw)
In-Reply-To: <20140626060136.GA2528@thin>

On Wed, 2014-06-25 at 23:01 -0700, Josh Triplett wrote:
> Currently, LONG_LINE just informs the user about the line length,
> leaving them to shorten the line.  Too many users run checkpatch and
> blindly follow its recommendation by splitting long lines, which almost
> invariably results in worse code.  On rare occasions, the line-width
> limit encourages sensible refactoring of nested code into functions, but
> more frequently it just results in painfully over-wrapped code.
> 
> Improve the guidance by detecting long lines that start with 4+ tabs and
> explicitly suggesting simplification or refactoring in that case.
[]
> diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
[]
> @@ -2146,8 +2146,16 @@ sub process {
>  		    $line =~ /^\+\s*"[^"]*"\s*(?:\s*|,|\)\s*;)\s*$/) &&
>  		    $length > $max_line_length)
>  		{
> -			WARN("LONG_LINE",
> -			     "line over $max_line_length characters\n" . $herecurr);
> +			if ($line =~ /^\+\t{4,}/) {
> +				WARN("LONG_LINE_DEEP_NESTING",
> +				     "line over $max_line_length characters with excessive nesting (4+ tabs)\n"
> +				     . "Consider simplifying or refactoring to eliminate excessive nesting.\n"
> +				     . $herecurr);

This is not the test you want.

This is also emitting on lines that are
merely continued like
			pr_warning(format,
				   arg1,
				   arg2,
				   arg3
				   ...
				   argN);

Better would be to test only for the lines
that increase indents (like the DEEP_INDENTATION test)

$line =~ /^\+\t{4,}(?:if|for|while|do|switch)\b/

This is the treewide distribution I get for the lines
that generally produce extra indentation:

 608432 1
 242180 2
  71260 3
  16953 4
   3688 5
    758 6
    187 7
     74 8
     23 9
     17 10
      8 11
      4 12
      1 13



      reply	other threads:[~2014-06-26 10:10 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-06-26  6:01 Josh Triplett
2014-06-26 10:09 ` Joe Perches [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1403777345.7977.36.camel@joe-AO725 \
    --to=joe@perches.com \
    --cc=akpm@linux-foundation.org \
    --cc=apw@canonical.com \
    --cc=gregkh@linux-foundation.org \
    --cc=josh@joshtriplett.org \
    --cc=linux-kernel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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®