Subject: [PATCH 0/3] checkpatch: enhance Kconfig parsing

Enhance parsing for Kconfig patches and files.

Robert Elliott (3):
checkpatch: improve Kconfig help text patch parsing
checkpatch: don't sanitise quotes in Kconfig files
checkpatch: check line length in Kconfig help text

scripts/checkpatch.pl | 38 ++++++++++++++++++++++++++++++--------
1 file changed, 30 insertions(+), 8 deletions(-)

--
2.37.1


Subject: [PATCH 3/3] checkpatch: check line length in Kconfig help text

Apply the normal --max-line-length=nn line length checks to
Kconfig help text.

The default of 100 is only triggered by one existing line in
a file named Kconfig. Running with --max-line-length=80 reports
only a few long lines:
- 11 between 90 and 99 characters
- 25 betwen 81 and 89 characters
9 of which are due to long URLs.

Signed-off-by: Robert Elliott <[email protected]>
---
scripts/checkpatch.pl | 21 ++++++++++++++++++---
1 file changed, 18 insertions(+), 3 deletions(-)

diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
index 4d09a324a586..f8e48af40b81 100755
--- a/scripts/checkpatch.pl
+++ b/scripts/checkpatch.pl
@@ -3495,7 +3495,7 @@ sub process {
next if ($f =~ /^-/);
last if ($f !~ /^[\+ ]/); # !patch context

- if ($f =~ /^[\+ ]\s*(?:bool|tristate|prompt)\s*["']/) {
+ if ($f =~ /^[\+ ]\s*(?:bool|tristate|string|hex|int|prompt)\s*["']/) {
$needs_help = 1;
next;
}
@@ -3514,12 +3514,27 @@ sub process {
# and so hopefully shouldn't trigger false
# positives, even though some of these are
# common words in help texts
- if ($f =~ /^(?:config|menuconfig|choice|endchoice|
- if|endif|menu|endmenu|source)\b/x) {
+ if ($f =~ /^(?:config|menuconfig|
+ choice|endchoice|
+ comment|if|endif|
+ menu|endmenu|source)\b/x) {
last;
}
+
+ # no further checking for lines with these keywords
+ if ($f =~ /^(?:default|def_bool|depends|select|imply)\b/x) {
+ next;
+ }
+
+ my ($length, $indent) = line_stats($f);
+ if ($length > $max_line_length) {
+ WARN("CONFIG_DESCRIPTION",
+ "Kconfig help text line length ($length) too long: $f\n");
+ }
+
$help_length++ if ($has_help);
}
+
if ($needs_help &&
$help_length < $min_conf_desc_length) {
my $stat_real = get_stat_real($linenr, $ln - 1);
--
2.37.1

Subject: [PATCH 2/3] checkpatch: don't sanitise quotes in Kconfig files

If Kconfig help text contains a single quote (e.g., can't),
checkpatch replaces all characters with X until another quote
appears in some later help text. This interferes with processing
keywords.

Don't sanitise lines if the file is a Kconfig file.

Signed-off-by: Robert Elliott <[email protected]>
---
scripts/checkpatch.pl | 12 +++++++++---
1 file changed, 9 insertions(+), 3 deletions(-)

diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
index b0cda2f6414d..4d09a324a586 100755
--- a/scripts/checkpatch.pl
+++ b/scripts/checkpatch.pl
@@ -2714,9 +2714,15 @@ sub process {
sanitise_line_reset($in_comment);

} elsif ($realcnt && $rawline =~ /^(?:\+| |$)/) {
- # Standardise the strings and chars within the input to
- # simplify matching -- only bother with positive lines.
- $line = sanitise_line($rawline);
+ if (($realfile =~ /Kconfig/) ||
+ (!$is_patch && $filename =~ /Kconfig/)) {
+ # Kconfig help text is free to use unmatched quotes
+ $line = $rawline;
+ } else {
+ # Standardise the strings and chars within the input to
+ # simplify matching -- only bother with positive lines.
+ $line = sanitise_line($rawline);
+ }
}
push(@lines, $line);

--
2.37.1

Subject: [PATCH v2 0/5] checkpatch: enhance Kconfig parsing

Enhance parsing for Kconfig patches and files.

Robert Elliott (5):
checkpatch: improve Kconfig help text patch parsing
checkpatch: don't sanitise quotes in Kconfig files
checkpatch: check line length in Kconfig help text
checkpatch: discard processed lines
checkpatch: ignore a file named b

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

--
2.38.1

Subject: [PATCH v2 2/5] checkpatch: don't sanitise quotes in Kconfig files

If Kconfig help text contains a single quote (e.g., can't),
checkpatch replaces all characters with X until another quote
appears in some later help text. This interferes with processing
keywords.

Don't sanitise lines if the file is a Kconfig file.

Signed-off-by: Robert Elliott <[email protected]>
---
scripts/checkpatch.pl | 12 +++++++++---
1 file changed, 9 insertions(+), 3 deletions(-)

diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
index 1d9e563e768a..c907d5cf0ac8 100755
--- a/scripts/checkpatch.pl
+++ b/scripts/checkpatch.pl
@@ -2715,9 +2715,15 @@ sub process {
sanitise_line_reset($in_comment);

} elsif ($realcnt && $rawline =~ /^(?:\+| |$)/) {
- # Standardise the strings and chars within the input to
- # simplify matching -- only bother with positive lines.
- $line = sanitise_line($rawline);
+ if (($realfile =~ /Kconfig/) ||
+ (!$is_patch && $filename =~ /Kconfig/)) {
+ # Kconfig help text is free to use unmatched quotes
+ $line = $rawline;
+ } else {
+ # Standardise the strings and chars within the input to
+ # simplify matching -- only bother with positive lines.
+ $line = sanitise_line($rawline);
+ }
}
push(@lines, $line);

--
2.38.1