From 38add74bd6bdcca7f720b669ba8aef33e1a8f5a5 Mon Sep 17 00:00:00 2001 From: Taiki Endo Date: Mon, 3 Feb 2025 03:04:04 +0900 Subject: [PATCH] Update cspell config & dictionary --- .cspell.json | 15 ++++---- .github/.cspell/organization-dictionary.txt | 39 ++------------------ .github/workflows/ci.yml | 8 ++++ tools/cspell-dict.sh | 41 +++++++++++++++++++++ 4 files changed, 61 insertions(+), 42 deletions(-) create mode 100755 tools/cspell-dict.sh diff --git a/.cspell.json b/.cspell.json index 33996c3..e80166a 100644 --- a/.cspell.json +++ b/.cspell.json @@ -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": [] diff --git a/.github/.cspell/organization-dictionary.txt b/.github/.cspell/organization-dictionary.txt index 4bb99aa..5c83e4e 100644 --- a/.github/.cspell/organization-dictionary.txt +++ b/.github/.cspell/organization-dictionary.txt @@ -8,7 +8,6 @@ asan cdylib cflags clif -clippy codegen cranelift cxxflags @@ -19,11 +18,9 @@ miriflags msan rlib rustc -rustdoc rustdocflags rustflags rustsec -rustup staticlib tsan xcompile @@ -31,7 +28,6 @@ Zmiri // Rust target triple/spec aarch -amdgpu androideabi armeb armebv @@ -40,10 +36,8 @@ atmega bpfeb bpfel csky -cuda eabi eabihf -emscripten espidf fortanix gnuabi @@ -62,7 +56,6 @@ loongarch macabi mipsel mipsisa -msvc muslabi musleabi musleabihf @@ -104,83 +97,62 @@ 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 moreutils -msys noconfirm noninteractive noprofile norc -nproc nullary -objcopy -objdump pacman pkgin powerset @@ -189,15 +161,12 @@ readelf requirechecksums sched semihosting -shellcheckrc SIGABRT -SIGBUS SIGILL STOPSIGNAL subcmd taplo tlsv -tmpdir tomlq valgrind venv diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index b651bc0..1dde010 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -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 diff --git a/tools/cspell-dict.sh b/tools/cspell-dict.sh new file mode 100755 index 0000000..d184421 --- /dev/null +++ b/tools/cspell-dict.sh @@ -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