Ignore username in todo comment in spell-check

This commit is contained in:
Taiki Endo
2023-03-30 22:39:28 +09:00
parent 1c96e2750b
commit 28dd623da7
3 changed files with 26 additions and 6 deletions

View File

@@ -26,7 +26,7 @@
],
"ignoreRegExpList": [
// Copyright notice
"Copyright ((\\(c\\)|\\(C\\)|©) )?.*",
"Copyright .*",
// GHA actions/workflows
"uses: .+@",
// GHA context (repo name, owner name, etc.)
@@ -35,6 +35,8 @@
"( |\\[)@[\\w_-]+",
// Git config username
"git config user.name .*",
// Username in todo comment
"(TODO|FIXME)\\([\\w_., -]+\\)",
// Cargo.toml authors
"authors *= *\\[.*\\]",
"\".* <[\\w_.+-]+@[\\w.-]+>\""

View File

@@ -85,6 +85,7 @@ acqrel
alloc
bools
builtins
bytecount
canonicalize
consts
ctypes
@@ -98,6 +99,7 @@ inlateout
intrinsics
lateout
mclass
memcpy
msrv
nand
nomem
@@ -110,6 +112,7 @@ rclass
repr
rfind
rfold
rposition
rsplit
rustlib
seqcst
@@ -124,6 +127,8 @@ unsized
upcastable
// Other
armel
armhf
binutils
connrefused
cygwin

View File

@@ -41,6 +41,14 @@ warn() {
fi
should_fail=1
}
error() {
if [[ -n "${GITHUB_ACTIONS:-}" ]]; then
echo "::error::$*"
else
echo >&2 "error: $*"
fi
should_fail=1
}
if [[ $# -gt 0 ]]; then
cat <<EOF
@@ -70,6 +78,11 @@ if [[ -n "$(git ls-files '*.rs')" ]]; then
else
warn "'rustup' is not installed"
fi
cast_without_turbofish=$(grep -n -E '\.cast\(\)' $(git ls-files '*.rs') || true)
if [[ -n "${cast_without_turbofish}" ]]; then
error "please replace \`.cast()\` with \`.cast::<type_name>()\`:"
echo "${cast_without_turbofish}"
fi
fi
# C/C++ (if exists)
@@ -103,8 +116,8 @@ if [[ -n "$(git ls-files '*.yml')$(git ls-files '*.js')$(git ls-files '*.json')"
permissions=$(yq '.permissions' "${workflow}" | jq -c)
case "${permissions}" in
'{"contents":"read"}' | '{"contents":"none"}' | '{}') ;;
null) warn "${workflow}: top level permissions not found; it must be 'contents: read' or weaker permissions" ;;
*) warn "${workflow}: only 'contents: read' and weaker permissions are allowed at top level; if you want to use stronger permissions, please set job-level permissions" ;;
null) error "${workflow}: top level permissions not found; it must be 'contents: read' or weaker permissions" ;;
*) error "${workflow}: only 'contents: read' and weaker permissions are allowed at top level; if you want to use stronger permissions, please set job-level permissions" ;;
esac
# Make sure the 'needs' section is not out of date.
if grep -q '# tidy:needs' "${workflow}" && ! grep -Eq '# *needs: \[' "${workflow}"; then
@@ -117,7 +130,7 @@ if [[ -n "$(git ls-files '*.yml')$(git ls-files '*.js')$(git ls-files '*.json')"
printf -v jobs '%s, ' "${jobs_actual[@]}"
sed -i "s/needs: \[.*\] # tidy:needs/needs: [${jobs%, }] # tidy:needs/" "${workflow}"
check_diff "${workflow}"
warn "${workflow}: please update 'needs' section in 'ci-success' job"
error "${workflow}: please update 'needs' section in 'ci-success' job"
fi
fi
done
@@ -127,7 +140,7 @@ if [[ -n "$(git ls-files '*.yml')$(git ls-files '*.js')$(git ls-files '*.json')"
fi
fi
if [[ -n "$(git ls-files '*.yaml')" ]]; then
warn "please use '.yml' instead of '.yaml' for consistency"
error "please use '.yml' instead of '.yaml' for consistency"
git ls-files '*.yaml'
fi
@@ -199,7 +212,7 @@ EOF
fi
dup=$(sed '/^$/d' .github/.cspell/project-dictionary.txt "${dictionary}" | LC_ALL=C sort -f | uniq -d -i | (grep -v '//.*' || true))
if [[ -n "${dup}" ]]; then
warn "duplicated words in dictionaries; please remove the following words from .github/.cspell/project-dictionary.txt"
error "duplicated words in dictionaries; please remove the following words from .github/.cspell/project-dictionary.txt"
echo "======================================="
echo "${dup}"
echo "======================================="