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

Joe Perches
2020-06-10T07:13:48Z

On Wed, 2020-06-10 at 08:52 +0200, SeongJae Park wrote:
> From: SeongJae Park <sjpark@amazon.de>
>
> 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.