lkml.org 
[lkml]   [2018]   [Jan]   [30]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
SubjectRe: [PATCH] checkpatch: warn if changed lines exceeds a maximum size
From
Date
On Tue, 2018-01-30 at 15:57 +0000, Brown, Nicholas wrote:
> Changed lines is the total of inserted and deleted lines.
> By default there is no limit, --max-changed-lines may be used to set a
> value. Some users may wish to encourage that patches are split into
> smaller parts using this.
> See Documentation/process/submitting-patches.rst#split-changes

(This patch seems whitespace damaged)

I don't care for this much as is either.

This patch doesn't add help text and it
should probably add a check for
"if (!$file"
so new files aren't size limited.

Also, it double counts lines that are
added and deleted so doing things like
refactoring a block of code into a new
separate function would potentially trip
this.

> Signed-off-by: Nicholas Brown <nick.brown@att.com>
> ---
> scripts/checkpatch.pl | 17 +++++++++++++++++
> 1 file changed, 17 insertions(+)
>
> diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
> index 31031f10fe56..1217d782b6bb 100755
> --- a/scripts/checkpatch.pl
> +++ b/scripts/checkpatch.pl
> @@ -49,6 +49,7 @@ my @ignore = ();
> my $help = 0;
> my $configuration_file = ".checkpatch.conf";
> my $max_line_length = 80;
> +my $max_changed_lines; # undef = no max
> my $ignore_perl_version = 0;
> my $minimum_perl_version = 5.10.0;
> my $min_conf_desc_length = 4;
> @@ -209,6 +210,7 @@ GetOptions(
> 'show-types!' => \$show_types,
> 'list-types!' => \$list_types,
> 'max-line-length=i' => \$max_line_length,
> + 'max-changed-lines=i' => \$max_changed_lines,
> 'min-conf-desc-length=i' => \$min_conf_desc_length,
> 'root=s' => \$root,
> 'summary!' => \$summary,
> @@ -2165,6 +2167,8 @@ sub process {
> my $filename = shift;
>
> my $linenr=0;
> + my $inserted_lines_total=0;
> + my $deleted_lines_total=0;
> my $prevline="";
> my $prevrawline="";
> my $stashline="";
> @@ -2233,6 +2237,14 @@ sub process {
>
> push(@fixed, $rawline) if ($fix);
>
> + if ($rawline=~/^\+/) {
> + $inserted_lines_total++
> + }
> +
> + if ($rawline=~/^-/) {
> + $deleted_lines_total++
> + }
> +
> if ($rawline=~/^\+\+\+\s+(\S+)/) {
> $setup_docs = 0;
> if ($1 =~ m@Documentation/admin-guide/kernel-parameters.rst$@) {
> @@ -2306,6 +2318,11 @@ sub process {
>
> $prefix = '';
>
> + if (defined $max_changed_lines &&
> + ($inserted_lines_total+$deleted_lines_total > $max_changed_lines)) {
> + WARN("MAX_CHANGED_LINES", "please split the change into smaller parts\n");
> + }
> +
> $realcnt = 0;
> $linenr = 0;
> $fixlinenr = -1;
> --
> 2.14.1

\
 
 \ /
  Last update: 2018-01-30 17:10    [W:0.067 / U:0.024 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site