Re: Re: [PATCH v3 1/2] checkpatch: support deprecated terms checking

From: SeongJae Park
Date: Wed Jun 10 2020 - 04:01:28 EST


On Wed, 10 Jun 2020 00:13:42 -0700 Joe Perches <joe@xxxxxxxxxxx> wrote:

> On Wed, 2020-06-10 at 08:52 +0200, SeongJae Park wrote:
> > From: SeongJae Park <sjpark@xxxxxxxxx>
> >
> > Some terms could be deprecated for various reasons, but it is hard to
> > update the entire old usages. That said, we could at least encourage
> > new patches to use the suggested replacements. This commit adds check
> > of deprecated terms in the 'checkpatch.pl' for that. The script will
> > get deprecated terms and suggested replacements of those from
> > 'scripts/deprecated_terms.txt' file and warn if the deprecated terms are
> > used. The mechanism and the format of the file are almost the same as
> > that of 'spelling.txt'.
> []
> > diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
> []
> > +# Load deprecated terms and build regular expression list.
> > +my $deprecated_terms;
> > +my %deprecated_terms_fix;
> > +
> > +if (open(my $deprecates, '<', $deprecated_terms_file)) {
> > + while (<$deprecates>) {
> > + my $line = $_;
> > +
> > + $line =~ s/\s*\n?$//g;
> > + $line =~ s/^\s*//g;
> > +
> > + next if ($line =~ m/^\s*#/);
> > + next if ($line =~ m/^\s*$/);
> > +
> > + my ($suspect, $fix) = split(/\|\|/, $line);
> > +
> > + $deprecated_terms_fix{$suspect} = $fix;
> > + }
> > + close($deprecates);
> > +} else {
> > + warn "No deprecated term will be found - file '$deprecated_terms_file': $!\n";
> > +}
> > +
> > +$deprecated_terms = join("|", sort keys %deprecated_terms_fix) if keys %deprecated_terms_fix;
> > +
>
> This is a direct copy of the spelling dictionary
> loading code, so maybe these could be consolidated.

Agreed, how about below one?

============================= >8 ============================================