Re: [PATCH v3 3/5] checkpatch: kconfig: enforce help text indentation

From: Nicolai Fischer
Date: Tue Jan 05 2021 - 10:50:46 EST




On Tue 05.01.21 09:57, Joe Perches wrote:
> On Mon, 2021-01-04 at 14:09 -0800, Joe Perches wrote:
>> On Sun, 2021-01-03 at 08:50 +0100, Nicolai Fischer wrote:
>>> Adds a new warning in case the indentation level of the
>>> first line of a Kconfig help message is not at least 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@xxxxxx>
>>> Signed-off-by: Johannes Czekay <johannes.czekay@xxxxxx>
>>> Signed-off-by: Nicolai Fischer <nicolai.fischer@xxxxxx>
>>> ---
>>>
>>> Now matches indentation of two or more spaces, instead of exactly two.
>>
>> No, this should match exactly 2 and warn on any other use.
>
> To clarify, only the first line after the help keyword needs to
> have a 2 space indent more than the help keyword and the help
> block may start with Kconfig keywords.
>> Subsequent help block lines may have more than 2 chars.

Okay, thank you for the clarification.

>
> The help block line count should end when the indent is less than
> the help keyword indent and is a non-blank line.

We could do something like this

if (defined $help_indent) {
$lines[$ln - 1] =~ /^\+(\s*)\S+/;
if (length($1) < length($help_indent)) {
is_end = 1; last;
}

as an extra patch after patch 3.

Please clarify whether we should match for a smaller indent than the help
keyword or the first non-blank line after the keyword.


>
> This should be valid:
>
> help
> line 1
> -- reason 1
> -- reason 2
> continuation
> -- reason 3
>
> But this should warn only on line 1:
>
> help
> line 1 has a 3 space indent
> -- reason 1
> -- reason 2
> continuation
> -- reason 3
>
>