mirror of
https://github.com/curl/curl.git
synced 2026-04-21 14:12:12 +03:00
GHA: add a job scanning for "bad words" in markdown
This means words, phrases or things we have decided not to use - words that are spelled right according to the dictionary but we want to avoid. In the name of consistency and better documentation. Closes #12764
This commit is contained in:
parent
2620aa930b
commit
e5000e797f
93 changed files with 530 additions and 348 deletions
67
.github/scripts/badwords.pl
vendored
Executable file
67
.github/scripts/badwords.pl
vendored
Executable file
|
|
@ -0,0 +1,67 @@
|
|||
#!/usr/bin/perl
|
||||
# Copyright (C) Daniel Stenberg, <daniel@haxx.se>, et al.
|
||||
#
|
||||
# SPDX-License-Identifier: curl
|
||||
#
|
||||
# bad[:=]correct
|
||||
#
|
||||
# If separator is '=', the string will be compared case sensitively.
|
||||
# If separator is ':', the check is done case insensitively.
|
||||
#
|
||||
my $w;
|
||||
while(<STDIN>) {
|
||||
chomp;
|
||||
if($_ =~ /^#/) {
|
||||
next;
|
||||
}
|
||||
if($_ =~ /^([^:=]*)([:=])(.*)/) {
|
||||
my ($bad, $sep, $better)=($1, $2, $3);
|
||||
push @w, $bad;
|
||||
$alt{$bad} = $better;
|
||||
if($sep eq "=") {
|
||||
$exactcase{$bad} = 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
my $errors;
|
||||
|
||||
sub file {
|
||||
my ($f) = @_;
|
||||
my $l = 0;
|
||||
open(F, "<$f");
|
||||
while(<F>) {
|
||||
my $in = $_;
|
||||
$l++;
|
||||
chomp $in;
|
||||
if($in =~ /^ /) {
|
||||
next;
|
||||
}
|
||||
# remove the link part
|
||||
$in =~ s/(\[.*\])\(.*\)/$1/g;
|
||||
# remove backticked texts
|
||||
$in =~ s/\`.*\`//g;
|
||||
foreach my $w (@w) {
|
||||
my $case = $exactcase{$w};
|
||||
if(($in =~ /^(.*)$w/i && !$case) ||
|
||||
($in =~ /^(.*)$w/ && $case) ) {
|
||||
my $p = $1;
|
||||
my $c = length($p)+1;
|
||||
print STDERR "$f:$l:$c: error: found bad word \"$w\"\n";
|
||||
printf STDERR " %4d | $in\n", $l;
|
||||
printf STDERR " | %*s^%s\n", length($p), " ",
|
||||
"~" x (length($w)-1);
|
||||
printf STDERR " maybe use \"%s\" instead?\n", $alt{$w};
|
||||
$errors++;
|
||||
}
|
||||
}
|
||||
}
|
||||
close(F);
|
||||
}
|
||||
|
||||
my @files = @ARGV;
|
||||
|
||||
foreach my $each (@files) {
|
||||
file($each);
|
||||
}
|
||||
exit $errors;
|
||||
45
.github/scripts/badwords.txt
vendored
Normal file
45
.github/scripts/badwords.txt
vendored
Normal file
|
|
@ -0,0 +1,45 @@
|
|||
# Copyright (C) Daniel Stenberg, <daniel@haxx.se>, et al.
|
||||
#
|
||||
# SPDX-License-Identifier: curl
|
||||
#
|
||||
back-end:backend
|
||||
e-mail:email
|
||||
run-time:runtime
|
||||
set-up:setup
|
||||
tool chain:toolchain
|
||||
tool-chain:toolchain
|
||||
wild-card:wildcard
|
||||
wild card:wildcard
|
||||
i'm:I am
|
||||
you've:You have
|
||||
they've:They have
|
||||
they're:They are
|
||||
should've:should have
|
||||
don't:do not
|
||||
could've:could have
|
||||
doesn't:does not
|
||||
isn't:is not
|
||||
a html: an html
|
||||
a http: an http
|
||||
a ftp: an ftp
|
||||
url =URL
|
||||
internet\W=Internet
|
||||
isation:ization
|
||||
it's:it is
|
||||
there's:there is
|
||||
[^.]\. And: Rewrite it somehow?
|
||||
\. But: Rewrite it somehow?
|
||||
file name :filename
|
||||
\. So : Rewrite without "so" ?
|
||||
dir :directory
|
||||
you'd:you would
|
||||
you'll:you will
|
||||
can't:cannot
|
||||
that's:that is
|
||||
web page:webpage
|
||||
host name\W:hostname
|
||||
file name\W:filename
|
||||
didn't:did not
|
||||
doesn't:does not
|
||||
won't:will not
|
||||
couldn't:could not
|
||||
1
.github/scripts/spellcheck.words
vendored
1
.github/scripts/spellcheck.words
vendored
|
|
@ -885,6 +885,7 @@ WB
|
|||
web page
|
||||
WebDAV
|
||||
WebOS
|
||||
webpage
|
||||
WebSocket
|
||||
WEBSOCKET
|
||||
WHATWG
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue