Skip to content

Commit

Permalink
Update cspell config & dictionary
Browse files Browse the repository at this point in the history
  • Loading branch information
taiki-e committed Feb 2, 2025
1 parent 9918b34 commit 64d983c
Show file tree
Hide file tree
Showing 5 changed files with 67 additions and 48 deletions.
15 changes: 8 additions & 7 deletions .cspell.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,24 +27,25 @@
"ignoreRegExpList": [
// Copyright notice
"Copyright .*",
"SPDX-(File|Snippet)CopyrightText: .*",
// GHA actions/workflows
"uses: .+@",
"uses: .+@[\\w_.-]+",
// GHA context (repo name, owner name, etc.)
"github.\\w+ (=|!)= '.+'",
"github.[\\w_.-]+ (=|!)= '[^']+'",
// GH username
"( |\\[)@[\\w_-]+",
// Git config username
"git config user.name .*",
// Username in todo comment
"git config( --[^ ]+)? user.name .*",
// Username in TODO|FIXME comment
"(TODO|FIXME)\\([\\w_., -]+\\)",
// Cargo.toml authors
"authors *= *\\[.*\\]",
"\".* <[\\w_.+-]+@[\\w.-]+>\""
"authors *= *\\[[^\\]]*\\]",
"\"[^\"]* <[\\w_.+-]+@[\\w.-]+>\""
],
"languageSettings": [
{
"languageId": ["*"],
"dictionaries": ["bash", "rust"]
"dictionaries": ["bash", "cpp-refined", "rust"]
}
],
"ignorePaths": []
Expand Down
40 changes: 5 additions & 35 deletions .github/.cspell/organization-dictionary.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ asan
cdylib
cflags
clif
clippy
codegen
cranelift
cxxflags
Expand All @@ -19,19 +18,16 @@ miriflags
msan
rlib
rustc
rustdoc
rustdocflags
rustflags
rustsec
rustup
staticlib
tsan
xcompile
Zmiri

// Rust target triple/spec
aarch
amdgpu
androideabi
armeb
armebv
Expand All @@ -40,10 +36,8 @@ atmega
bpfeb
bpfel
csky
cuda
eabi
eabihf
emscripten
espidf
fortanix
gnuabi
Expand All @@ -62,7 +56,6 @@ loongarch
macabi
mipsel
mipsisa
msvc
muslabi
musleabi
musleabihf
Expand Down Expand Up @@ -104,83 +97,63 @@ bufs
bytecount
cfgs
ctypes
dealloc
deque
docsrs
doctest
doctests
elems
idents
ilog
impls
incompat
inlateout
lateout
libdir
mclass
memcpy
nand
nanos
nocapture
nomem
nonminimal
nonoverlapping
noreturn
nostack
peekable
powf
punct
rchunks
rclass
repr
rfind
rfold
rposition
rsplit
rustlib
seqcst
simd
splitn
structs
subsec
supertrait
supertraits
sysroot
turbofish
uninit
unpark
unparse
upcastable

// Other
armel
armhf
backports
binutils
choco
chsh
connrefused
devel
dockerfiles
endgroup
endianness
euxo
exitcode
ggrep
gsed
gsub
gtar
HEALTHCHECK
libc
markdownlint
mmap
libunwind
machdep
moreutils
msys
noconfirm
noninteractive
noprofile
norc
nproc
nullary
objcopy
objdump
pacman
pkgin
powerset
Expand All @@ -189,15 +162,12 @@ readelf
requirechecksums
sched
semihosting
shellcheckrc
SIGABRT
SIGBUS
SIGILL
STOPSIGNAL
subcmd
taplo
tlsv
tmpdir
tomlq
valgrind
venv
Expand Down
8 changes: 8 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -119,3 +119,11 @@ jobs:
steps:
- uses: taiki-e/checkout-action@v1
- uses: ./setup-docker

cspell-dict:
runs-on: ubuntu-latest
timeout-minutes: 60
steps:
- uses: taiki-e/checkout-action@v1
- run: tools/cspell-dict.sh clean
- run: git add -N . && git diff --exit-code
41 changes: 41 additions & 0 deletions tools/cspell-dict.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
#!/usr/bin/env bash
# SPDX-License-Identifier: Apache-2.0 OR MIT
# shellcheck disable=SC2013
set -CeEuo pipefail
IFS=$'\n\t'
trap -- 's=$?; printf >&2 "%s\n" "${0##*/}:${LINENO}: \`${BASH_COMMAND}\` exit with ${s}"; exit ${s}' ERR

bail() {
printf >&2 'error: %s\n' "$*"
exit 1
}

case "$1" in
clean)
cd -- "$(dirname -- "$0")"/..
dictionary=.github/.cspell/organization-dictionary.txt
grep_args=()
for word in $(grep -Ev '^//' "${dictionary}" || true); do
[[ -n "${word}" ]] || continue
if npx -y cspell trace "${word}" | grep -Fv "${dictionary}" | grep -Eq "^${word} \\* [^ ]+\*"; then
grep_args+=(-e "^${word}$")
fi
done
if [[ ${#grep_args[@]} -gt 0 ]]; then
printf 'info: %s\n' "removing needless words from ${dictionary}"
res=$(grep -Ev "${grep_args[@]}" "${dictionary}")
printf '%s\n' "${res}" >|"${dictionary}"
fi
;;
trace)
for dictionary in .github/.cspell/*; do
if [[ -f "${dictionary}" ]]; then
for word in $(grep -Ev '^//' "${dictionary}" || true); do
[[ -n "${word}" ]] || continue
npx -y cspell trace "${word}" | grep -E "^${word} \\*" | { grep -Fv "${dictionary}" || true; }
done
fi
done
;;
*) bail "unrecognized subcommand '$1'" ;;
esac
11 changes: 5 additions & 6 deletions tools/tidy.sh
Original file line number Diff line number Diff line change
Expand Up @@ -162,12 +162,11 @@ case "$(uname -s)" in
# GNU/BSD grep/sed is required to run some checks, but most checks are okay with other POSIX grep/sed.
# Solaris /usr/xpg4/bin/grep has -q, -E, -F, but no -o (non-POSIX).
# Solaris /usr/xpg4/bin/sed has no -E (POSIX.1-2024) yet.
if type -P ggrep >/dev/null; then
grep() { ggrep "$@"; }
fi
if type -P gsed >/dev/null; then
sed() { gsed "$@"; }
fi
for tool in sed grep; do
if type -P "g${tool}" >/dev/null; then
eval "${tool}() { g${tool} \"\$@\"; }"
fi
done
fi
;;
MINGW* | MSYS* | CYGWIN* | Windows_NT)
Expand Down

0 comments on commit 64d983c

Please sign in to comment.