2020-12-14 11:04:40

by Nicolai Fischer

[permalink] [raw]
Subject: [PATCH 0/2] checkpatch: update kconfig parsing

This series updates the parsing of Kconfig files within checkpatch.pl
to the current state, as discussed previously.


Nicolai Fischer (2):
checkpatch: kconfig: replace '---help---' with 'help'
checkpatch: kconfig: add missing types to regex

scripts/checkpatch.pl | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)

--
2.28.0


2020-12-26 14:11:17

by Nicolai Fischer

[permalink] [raw]
Subject: [PATCH v2 0/4] checkpatch: update kconfig parsing

This series updates the parsing of Kconfig files within checkpatch.pl
to the current state, as discussed previously.

The second iteration contains two more patches.
Patch 3 adds a new warning regarding the indentation as discussed.
Patch 4 aims to clarify the existing warning.

Nicolai Fischer (4):
checkpatch: kconfig: replace '---help---' with 'help'
checkpatch: kconfig: add missing types to regex
checkpatch: kconfig: enforce help text indentation
checkpatch: kconfig: clarify warning for paragraph length

scripts/checkpatch.pl | 23 +++++++++++++++++++----
1 file changed, 19 insertions(+), 4 deletions(-)

--
2.29.2



2021-01-03 07:55:34

by Nicolai Fischer

[permalink] [raw]
Subject: [PATCH v3 0/5] update kconfig parsing

This series updates the parsing of Kconfig files within checkpatch.pl
to the current state, as discussed previously.

Third iteration fixes patch 3 and adds one new patch.
Patch 5 adds a new waring regarding the indentation of a Kconfig block


Nicolai Fischer (5):
checkpatch: kconfig: replace '---help---' with 'help'
checkpatch: kconfig: add missing types to regex
checkpatch: kconfig: enforce help text indentation
checkpatch: kconfig: clarify warning for paragraph length
checkpatch: kconfig: enforce block indentation

scripts/checkpatch.pl | 34 +++++++++++++++++++++++++++++-----
1 file changed, 29 insertions(+), 5 deletions(-)

--
2.29.2



2021-01-03 07:55:42

by Nicolai Fischer

[permalink] [raw]
Subject: [PATCH v3 5/5] checkpatch: kconfig: enforce block indentation

Adds a new warning to checkpatch in case a new Kconfig block
is not indented one sigle tab more than the keyword which
starts it.

Co-developed-by: Johannes Czekay <[email protected]>
Signed-off-by: Johannes Czekay <[email protected]>
Signed-off-by: Nicolai Fischer <[email protected]>
---
scripts/checkpatch.pl | 13 +++++++++++--
1 file changed, 11 insertions(+), 2 deletions(-)

diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
index 805b5870803f..8a82ea5c2eb3 100755
--- a/scripts/checkpatch.pl
+++ b/scripts/checkpatch.pl
@@ -3306,7 +3306,8 @@ sub process {
# 'choice' is usually the last thing on the line (though
# Kconfig supports named choices), so use a word boundary
# (\b) rather than a whitespace character (\s)
- $line =~ /^\+\s*(?:config|menuconfig|choice)\b/) {
+ $line =~ /^\+(\s*)(?:config|menuconfig|choice)\b/) {
+ my $base_indent = $1;
my $length = 0;
my $cnt = $realcnt;
my $ln = $linenr + 1;
@@ -3315,6 +3316,7 @@ sub process {
my $is_end = 0;
my $help_indent;
my $help_stat_real;
+ my $block_stat_real;
for (; $cnt > 0 && defined $lines[$ln - 1]; $ln++) {
$f = $lines[$ln - 1];
$cnt-- if ($lines[$ln - 1] !~ /^-/);
@@ -3323,7 +3325,10 @@ sub process {
next if ($f =~ /^-/);
last if (!$file && $f =~ /^\@\@/);

- if ($lines[$ln - 1] =~ /^\+\s*(?:bool|tristate|int|hex|string|prompt)\s*(?:["'].*)?$/) {
+ if ($lines[$ln - 1] =~ /^\+(\s*)(?:bool|tristate|int|hex|string|prompt)\s*(?:["'].*)?$/) {
+ if ($1 !~ /^$base_indent\t$/) {
+ $block_stat_real = get_stat_real($linenr, $ln);
+ }
$is_start = 1;
} elsif ($lines[$ln - 1] =~ /^\+(\s*)help$/) {
$help_indent = $1;
@@ -3358,6 +3363,10 @@ sub process {
WARN("CONFIG_DESCRIPTION",
"please write a paragraph ($length/$min_conf_desc_length lines) that describes the config symbol fully\n" . $herecurr);
}
+ if ($is_start && $is_end && defined $block_stat_real) {
+ WARN("CONFIG_DESCRIPTION",
+ "please indent the block a single tab more than the start\n" . "$here\n$block_stat_real\n");
+ }
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");
--
2.29.2