linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Nicolai Fischer <nicolai.fischer@fau.de>
To: linux-kernel@vger.kernel.org
Cc: apw@canonical.com, johannes.czekay@fau.de,
	linux-kernel@i4.cs.fau.de, joe@perches.com,
	akpm@linux-foundation.org
Subject: [PATCH v2 3/4] checkpatch: kconfig: enforce help text indentation
Date: Sat, 26 Dec 2020 15:05:10 +0100	[thread overview]
Message-ID: <20201226140511.662368-4-nicolai.fischer@fau.de> (raw)
In-Reply-To: <20201226140511.662368-1-nicolai.fischer@fau.de>

Adds a new warning in case the indentation level of the
first line of a Kconfig help message is not two spaces
higher than the keyword itself.
Blank lines between the message and the help keyword
are ignored.

Co-developed-by: Johannes Czekay <johannes.czekay@fau.de>
Signed-off-by: Johannes Czekay <johannes.czekay@fau.de>
Signed-off-by: Nicolai Fischer <nicolai.fischer@fau.de>
---
 scripts/checkpatch.pl | 19 +++++++++++++++++--
 1 file changed, 17 insertions(+), 2 deletions(-)

diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
index c86a971a3205..aa2205ee9ab8 100755
--- a/scripts/checkpatch.pl
+++ b/scripts/checkpatch.pl
@@ -3313,6 +3313,8 @@ sub process {
 			my $f;
 			my $is_start = 0;
 			my $is_end = 0;
+			my $help_indent;
+			my $help_stat_real;
 			for (; $cnt > 0 && defined $lines[$ln - 1]; $ln++) {
 				$f = $lines[$ln - 1];
 				$cnt-- if ($lines[$ln - 1] !~ /^-/);
@@ -3323,8 +3325,10 @@ sub process {
 
 				if ($lines[$ln - 1] =~ /^\+\s*(?:bool|tristate|int|hex|string|prompt)\s*(?:["'].*)?$/) {
 					$is_start = 1;
-				} elsif ($lines[$ln - 1] =~ /^\+\s*help$/) {
-					$length = -1;
+				} elsif ($lines[$ln - 1] =~ /^\+(\s*)help$/) {
+					$help_indent = $1;
+					$length = 0;
+					next;
 				}
 
 				$f =~ s/^.//;
@@ -3332,6 +3336,13 @@ sub process {
 				$f =~ s/^\s+//;
 				next if ($f =~ /^$/);
 
+				if (defined $help_indent) {
+					if ($lines[$ln - 1] !~ /^\+$help_indent\ {2}\S*/) {
+						$help_stat_real = get_stat_real($ln - 1, $ln);
+					}
+					undef $help_indent;
+				}
+
 				# This only checks context lines in the patch
 				# and so hopefully shouldn't trigger false
 				# positives, even though some of these are
@@ -3347,6 +3358,10 @@ sub process {
 				WARN("CONFIG_DESCRIPTION",
 				     "please write a paragraph that describes the config symbol fully\n" . $herecurr);
 			}
+			if ($is_start && $is_end && defined $help_stat_real) {
+				WARN("CONFIG_DESCRIPTION",
+				     "please indent the help text two spaces more than the keyword\n" . "$here\n$help_stat_real\n");
+			}
 			#print "is_start<$is_start> is_end<$is_end> length<$length>\n";
 		}
 
-- 
2.29.2


  parent reply	other threads:[~2020-12-26 14:07 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-12-14 10:22 [PATCH 0/2] checkpatch: update kconfig parsing Nicolai Fischer
2020-12-26 14:05 ` [PATCH v2 0/4] " Nicolai Fischer
2020-12-26 14:05   ` [PATCH v2 1/4] checkpatch: kconfig: replace '---help---' with 'help' Nicolai Fischer
2020-12-26 14:05   ` [PATCH v2 2/4] checkpatch: kconfig: add missing types to regex Nicolai Fischer
2020-12-26 14:05   ` Nicolai Fischer [this message]
2020-12-26 15:50     ` [PATCH v2 3/4] checkpatch: kconfig: enforce help text indentation Joe Perches
2020-12-26 14:05   ` [PATCH v2 4/4] checkpatch: kconfig: clarify warning for paragraph length Nicolai Fischer
2021-01-03  7:50   ` [PATCH v3 0/5] update kconfig parsing Nicolai Fischer
2021-01-03  7:50     ` [PATCH v3 1/5] checkpatch: kconfig: replace '---help---' with 'help' Nicolai Fischer
2021-01-03  7:50     ` [PATCH v3 2/5] checkpatch: kconfig: add missing types to regex Nicolai Fischer
2021-01-03  7:50     ` [PATCH v3 3/5] checkpatch: kconfig: enforce help text indentation Nicolai Fischer
2021-01-04 22:09       ` Joe Perches
2021-01-05  8:57         ` Joe Perches
2021-01-05 15:49           ` Nicolai Fischer
2021-01-03  7:50     ` [PATCH v3 4/5] checkpatch: kconfig: clarify warning for paragraph length Nicolai Fischer
2021-01-03  7:50     ` [PATCH v3 5/5] checkpatch: kconfig: enforce block indentation Nicolai Fischer

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=20201226140511.662368-4-nicolai.fischer@fau.de \
    --to=nicolai.fischer@fau.de \
    --cc=akpm@linux-foundation.org \
    --cc=apw@canonical.com \
    --cc=joe@perches.com \
    --cc=johannes.czekay@fau.de \
    --cc=linux-kernel@i4.cs.fau.de \
    --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;
as well as URLs for NNTP newsgroup(s).