lkml.org 
[lkml]   [2020]   [Jul]   [26]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
SubjectRe: Re: Re: Re: checkpatch: support deprecated terms checking
From
Date
On Sun, 2020-07-26 at 09:45 +0200, SeongJae Park wrote:
> diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
[]
> @@ -721,6 +721,7 @@ sub read_word_corrections {
> my %deprecated_terms_fix;
> read_word_corrections($deprecated_terms_file, \%deprecated_terms_fix);
> my $deprecated_terms = join("|", sort keys %deprecated_terms_fix) if keys %deprecated_terms_fix;
> +my %deprecated_terms_reported = map { $_ => 1 }

overly verbose naming and this doesn't need initialization here.

> @@ -2975,13 +2976,16 @@ sub process {
> ($in_commit_log || $line =~ /^(?:\+|Subject:)/i)) {
> while ($rawline =~ /(?:^|[^a-z@])($deprecated_terms)(?:\b|$|[^a-z@])/gi) {
> my $deprecated_term = $1;
> + last if (exists($deprecated_terms_reported{$deprecated_term}));

next if (...) to check if multiple terms exists on the same line

> + $deprecated_terms_reported{$deprecated_term} = 1;
> +

But this does need to be reset to empty when checking the next file

> my $suggested = $deprecated_terms_fix{lc($deprecated_term)};
> $suggested = ucfirst($suggested) if ($deprecated_term=~ /^[A-Z]/);
> $suggested = uc($suggested) if ($deprecated_term =~ /^[A-Z]+$/);
> my $msg_level = \&WARN;
> $msg_level = \&CHK if ($file);
> if (&{$msg_level}("DEPRECATED_TERM",
> - "Use of '$deprecated_term' is deprecated, please '$suggested', instead.\n" . $herecurr) &&
> + "Use of '$deprecated_term' is controversial - if not required by specification, perhaps '$suggested' instead. See: scripts/deprecated_terms.txt\n" . $herecurr) &&
> $fix) {
> $fixed[$fixlinenr] =~ s/(^|[^A-Za-z@])($deprecated_term)($|[^A-Za-z@])/$1$suggested$3/;

I think it simpler to avoid emitting this on existing files.

I do not want to encourage relatively inexperienced people
to run checkpatch and submit inappropriate patches.


\
 
 \ /
  Last update: 2020-07-26 16:51    [W:0.065 / U:0.128 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site