linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v3] scripts: checkpatch: Check multiple blank lines when deleting code
@ 2019-03-06 19:53 Alexandre Ghiti
  2019-03-17 15:49 ` Alex Ghiti
  0 siblings, 1 reply; 3+ messages in thread
From: Alexandre Ghiti @ 2019-03-06 19:53 UTC (permalink / raw)
  To: Andy Whitcroft, Joe Perches, linux-kernel; +Cc: Alexandre Ghiti

By matching only current line starting with '+', we miss the case
when deleting code makes consecutive blank lines appear: this patch
then makes it possible to detect this case by also matching current
line starting with ' ', which is an already existing blank line.

Signed-off-by: Alexandre Ghiti <alex@ghiti.fr>
---

Changes in v3 as suggested by Joe Perches:
	- Do not try to fix this case
	- Make this test separate from the insertion one so that warning
	  is more explicit

Changes in v2:
	- Fix the --fix option

 scripts/checkpatch.pl | 12 +++++++++++-
 1 file changed, 11 insertions(+), 1 deletion(-)

diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
index b737ca9d7204..c0728cff292f 100755
--- a/scripts/checkpatch.pl
+++ b/scripts/checkpatch.pl
@@ -3296,7 +3296,7 @@ sub process {
 			}
 		}
 
-# check for multiple consecutive blank lines
+# check for multiple consecutive blank lines caused by blank line insertion
 		if ($prevline =~ /^[\+ ]\s*$/ &&
 		    $line =~ /^\+\s*$/ &&
 		    $last_blank_line != ($linenr - 1)) {
@@ -3309,6 +3309,16 @@ sub process {
 			$last_blank_line = $linenr;
 		}
 
+# check for multiple consecutive blank lines caused by code deletion
+		if ($prevline =~ /^[\+ ]\s*$/ &&
+		    $line =~ /^ \s*$/ &&
+		    $last_blank_line != ($linenr - 1)) {
+			CHK("LINE_SPACING",
+			    "Avoid deleting lines that create consecutive blank lines\n" . $hereprev);
+
+			$last_blank_line = $linenr;
+		}
+
 # check for missing blank lines after declarations
 		if ($sline =~ /^\+\s+\S/ &&			#Not at char 1
 			# actual declarations
-- 
2.20.1


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH v3] scripts: checkpatch: Check multiple blank lines when deleting code
  2019-03-06 19:53 [PATCH v3] scripts: checkpatch: Check multiple blank lines when deleting code Alexandre Ghiti
@ 2019-03-17 15:49 ` Alex Ghiti
  2019-03-25  7:07   ` Alex Ghiti
  0 siblings, 1 reply; 3+ messages in thread
From: Alex Ghiti @ 2019-03-17 15:49 UTC (permalink / raw)
  To: Andy Whitcroft, Joe Perches, linux-kernel

On 3/6/19 2:53 PM, Alexandre Ghiti wrote:
> By matching only current line starting with '+', we miss the case
> when deleting code makes consecutive blank lines appear: this patch
> then makes it possible to detect this case by also matching current
> line starting with ' ', which is an already existing blank line.
>
> Signed-off-by: Alexandre Ghiti <alex@ghiti.fr>
> ---
>
> Changes in v3 as suggested by Joe Perches:
> 	- Do not try to fix this case
> 	- Make this test separate from the insertion one so that warning
> 	  is more explicit
>
> Changes in v2:
> 	- Fix the --fix option
>
>   scripts/checkpatch.pl | 12 +++++++++++-
>   1 file changed, 11 insertions(+), 1 deletion(-)
>
> diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
> index b737ca9d7204..c0728cff292f 100755
> --- a/scripts/checkpatch.pl
> +++ b/scripts/checkpatch.pl
> @@ -3296,7 +3296,7 @@ sub process {
>   			}
>   		}
>   
> -# check for multiple consecutive blank lines
> +# check for multiple consecutive blank lines caused by blank line insertion
>   		if ($prevline =~ /^[\+ ]\s*$/ &&
>   		    $line =~ /^\+\s*$/ &&
>   		    $last_blank_line != ($linenr - 1)) {
> @@ -3309,6 +3309,16 @@ sub process {
>   			$last_blank_line = $linenr;
>   		}
>   
> +# check for multiple consecutive blank lines caused by code deletion
> +		if ($prevline =~ /^[\+ ]\s*$/ &&
> +		    $line =~ /^ \s*$/ &&
> +		    $last_blank_line != ($linenr - 1)) {
> +			CHK("LINE_SPACING",
> +			    "Avoid deleting lines that create consecutive blank lines\n" . $hereprev);
> +
> +			$last_blank_line = $linenr;
> +		}
> +
>   # check for missing blank lines after declarations
>   		if ($sline =~ /^\+\s+\S/ &&			#Not at char 1
>   			# actual declarations


Hi Joe,

Can I do something more this patch ?

Thanks,

Alex


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH v3] scripts: checkpatch: Check multiple blank lines when deleting code
  2019-03-17 15:49 ` Alex Ghiti
@ 2019-03-25  7:07   ` Alex Ghiti
  0 siblings, 0 replies; 3+ messages in thread
From: Alex Ghiti @ 2019-03-25  7:07 UTC (permalink / raw)
  To: Andy Whitcroft, Joe Perches, linux-kernel

On 3/17/19 11:49 AM, Alex Ghiti wrote:
> On 3/6/19 2:53 PM, Alexandre Ghiti wrote:
>> By matching only current line starting with '+', we miss the case
>> when deleting code makes consecutive blank lines appear: this patch
>> then makes it possible to detect this case by also matching current
>> line starting with ' ', which is an already existing blank line.
>>
>> Signed-off-by: Alexandre Ghiti <alex@ghiti.fr>
>> ---
>>
>> Changes in v3 as suggested by Joe Perches:
>>     - Do not try to fix this case
>>     - Make this test separate from the insertion one so that warning
>>       is more explicit
>>
>> Changes in v2:
>>     - Fix the --fix option
>>
>>   scripts/checkpatch.pl | 12 +++++++++++-
>>   1 file changed, 11 insertions(+), 1 deletion(-)
>>
>> diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
>> index b737ca9d7204..c0728cff292f 100755
>> --- a/scripts/checkpatch.pl
>> +++ b/scripts/checkpatch.pl
>> @@ -3296,7 +3296,7 @@ sub process {
>>               }
>>           }
>>   -# check for multiple consecutive blank lines
>> +# check for multiple consecutive blank lines caused by blank line 
>> insertion
>>           if ($prevline =~ /^[\+ ]\s*$/ &&
>>               $line =~ /^\+\s*$/ &&
>>               $last_blank_line != ($linenr - 1)) {
>> @@ -3309,6 +3309,16 @@ sub process {
>>               $last_blank_line = $linenr;
>>           }
>>   +# check for multiple consecutive blank lines caused by code deletion
>> +        if ($prevline =~ /^[\+ ]\s*$/ &&
>> +            $line =~ /^ \s*$/ &&
>> +            $last_blank_line != ($linenr - 1)) {
>> +            CHK("LINE_SPACING",
>> +                "Avoid deleting lines that create consecutive blank 
>> lines\n" . $hereprev);
>> +
>> +            $last_blank_line = $linenr;
>> +        }
>> +
>>   # check for missing blank lines after declarations
>>           if ($sline =~ /^\+\s+\S/ &&            #Not at char 1
>>               # actual declarations
>
>
> Hi Joe,
>
> Can I do something more this patch ?
>
> Thanks,
>
> Alex
>

Hi,

Sorry for insisting, but do you consider this patch for inclusion ?

Thanks,

Alex

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2019-03-25  7:07 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-03-06 19:53 [PATCH v3] scripts: checkpatch: Check multiple blank lines when deleting code Alexandre Ghiti
2019-03-17 15:49 ` Alex Ghiti
2019-03-25  7:07   ` Alex Ghiti

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).