-
Notifications
You must be signed in to change notification settings - Fork 204
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add verify-spelling.sh for English words. #547
Add verify-spelling.sh for English words. #547
Conversation
✅ Deploy Preview for k8s-kwok canceled.
|
hack/verify-spelling.sh
Outdated
echo "Checking spelling..." | ||
ERROR_LOG="${TMP_DIR}/errors.log" | ||
|
||
find . -type f | grep -v .golangci.yaml | grep -v vendor/ | xargs misspell >"${ERROR_LOG}" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should have a list of allowed words, not the whole document excluded.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@wzshiming
thanks for review.
you means like the code below
skipping_file="${KUBE_ROOT}/scripts/.spelling_failures"
failing_packages=$(sed "s| | -e |g" "${skipping_file}")
And we add the .golangci.yaml
and vendor/
to .spelling_failures files?
Actually i used did it like that, but error shows,
So i update the code ..😂😂
If that , i will try again and test ..
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For more tools details see https://github.com/client9/misspell
Refer #514 to add verify-spelling.sh
and update-spelling.sh
with -i $(sed <"${spelling_words}" "s| |,|g")
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thanks .
I will do it later.
hack/update-spelling.sh
Outdated
|
||
function check() { | ||
#NOTE we use go install refer the go site :https://go.dev/doc/go-get-install-deprecation | ||
go install github.com/client9/misspell/cmd/misspell@${TOOL_VERSION} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So fast for review...😀😀 |
vendor dir is not exclude.. |
@wzshiming |
hack/verify-spelling.sh
Outdated
########## | ||
# This script verifies mispellings in location. Today it only supports | ||
# verifying English locale but can be modified in a future to support | ||
# other locales also | ||
# You need to run this script inside the root directory of "website" git repo. | ||
# | ||
# Syntax: verify-spelling.sh LOCALE | ||
# Example: verify-spelling.sh en | ||
# If no locale is passed, it will assume "en" | ||
# | ||
# Requirements: | ||
# - go v1.14 or superior version |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
########## | |
# This script verifies mispellings in location. Today it only supports | |
# verifying English locale but can be modified in a future to support | |
# other locales also | |
# You need to run this script inside the root directory of "website" git repo. | |
# | |
# Syntax: verify-spelling.sh LOCALE | |
# Example: verify-spelling.sh en | |
# If no locale is passed, it will assume "en" | |
# | |
# Requirements: | |
# - go v1.14 or superior version |
hack/verify-spelling.sh
Outdated
@@ -0,0 +1,42 @@ | |||
#!/usr/bin/env bash | |||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
hack/update-spelling.sh
Outdated
# cd to the root path | ||
ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd -P)" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
# cd to the root path | |
ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd -P)" | |
ROOT_DIR="$(realpath "$(dirname "${BASH_SOURCE[0]}")"/..)" |
hack/update-spelling.sh
Outdated
fi | ||
|
||
function check() { | ||
cd "${ROOT}" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
cd "${ROOT}" |
hack/update-spelling.sh
Outdated
|
||
# cleanup | ||
exitHandler() ( | ||
echo "Cleaning up..." | ||
rm -rf "${TMP_DIR}" | ||
) | ||
trap exitHandler EXIT |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
# cleanup | |
exitHandler() ( | |
echo "Cleaning up..." | |
rm -rf "${TMP_DIR}" | |
) | |
trap exitHandler EXIT |
hack/verify-all.sh
Outdated
if [[ "${VERIFY_SHELL_SPELLING:-true}" == "true" ]]; then | ||
echo "[*] Verifying spelling..." | ||
"${ROOT_DIR}"/hack/verify-spelling.sh || failed+=(shell-spelling) | ||
fi |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if [[ "${VERIFY_SHELL_SPELLING:-true}" == "true" ]]; then | |
echo "[*] Verifying spelling..." | |
"${ROOT_DIR}"/hack/verify-spelling.sh || failed+=(shell-spelling) | |
fi | |
if [[ "${VERIFY_SPELLING:-true}" == "true" ]]; then | |
echo "[*] Verifying spelling..." | |
"${ROOT_DIR}"/hack/verify-spelling.sh || failed+=(spelling) | |
fi |
hack/update-all.sh
Outdated
if [[ "${UPDATE_SHELL_SPELLING:-true}" == "true" ]]; then | ||
echo "[*] Update spelling..." | ||
"${ROOT_DIR}"/hack/update-spelling.sh || failed+=(shell-spelling) | ||
fi |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if [[ "${UPDATE_SHELL_SPELLING:-true}" == "true" ]]; then | |
echo "[*] Update spelling..." | |
"${ROOT_DIR}"/hack/update-spelling.sh || failed+=(shell-spelling) | |
fi | |
if [[ "${UPDATE_SPELLING:-true}" == "true" ]]; then | |
echo "[*] Update spelling..." | |
"${ROOT_DIR}"/hack/update-spelling.sh || failed+=(spelling) | |
fi |
hack/verify-spelling.sh
Outdated
@@ -0,0 +1,42 @@ | |||
#!/usr/bin/env bash | |||
|
|||
# Copyright 2019 The Kubernetes Authors. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
# Copyright 2019 The Kubernetes Authors. | |
# Copyright 2023 The Kubernetes Authors. |
hack/update-spelling.sh
Outdated
elif command -v "${GOPATH}/bin/misspell"; then | ||
COMMAND=("${GOPATH}/bin/misspell") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
elif command -v "${GOPATH}/bin/misspell"; then | |
COMMAND=("${GOPATH}/bin/misspell") | |
elif command -v "${ROOT_DIR}/bin/misspell"; then | |
COMMAND=("${ROOT_DIR}/bin/misspell") |
hack/update-spelling.sh
Outdated
go install github.com/client9/misspell/cmd/misspell@${TOOL_VERSION} | ||
COMMAND=(misspell) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
go install github.com/client9/misspell/cmd/misspell@${TOOL_VERSION} | |
COMMAND=(misspell) | |
GOBIN="${ROOT_DIR}/bin/" go install github.com/client9/misspell/cmd/misspell@${TOOL_VERSION} | |
COMMAND=("${ROOT_DIR}/bin/misspell") |
Good suggestion. |
hack/update-spelling.sh
Outdated
# check spelling | ||
echo "Checking spelling..." | ||
ignore="$(tr <"${allowd_spelling_words}" '\n' ',')" | ||
"${COMMAND[@]}" -i "${ignore}" "$(find . -not \( -path ./vendor\* -o -path ./.git\* \))" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
# check spelling | |
echo "Checking spelling..." | |
ignore="$(tr <"${allowd_spelling_words}" '\n' ',')" | |
"${COMMAND[@]}" -i "${ignore}" "$(find . -not \( -path ./vendor\* -o -path ./.git\* \))" | |
ignore="$(tr <"${allowd_spelling_words}" '\n' ',')" | |
"${COMMAND[@]}" -w -i "${ignore}" "$(find . -not \( -path ./vendor\* -o -path ./.git\* \))" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good suggestion.
with -w flag , So misspell can override the file.
And then git --no-pager diff --exit-code
can check the diff of the file.
Will update it later.
hack/update-spelling.sh
Outdated
elif command -v "${ROOT_DIR}/bin/misspell"; then | ||
COMMAND=("${ROOT_DIR}/bin/misspell") | ||
else | ||
#NOTE we use go install refer the go site :https://go.dev/doc/go-get-install-deprecation |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
#NOTE we use go install refer the go site :https://go.dev/doc/go-get-install-deprecation |
hack/update-spelling.sh
Outdated
TOOL_VERSION="v0.3.4" | ||
|
||
ROOT_DIR="$(realpath "$(dirname "${BASH_SOURCE[0]}")"/..)" | ||
allowd_spelling_words="${ROOT_DIR}/hack/allowd_spelling_words" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
allowd_spelling_words="${ROOT_DIR}/hack/allowd_spelling_words" | |
allowed_spelling_words="${ROOT_DIR}/hack/spelling.txt" |
hack/update-spelling.sh
Outdated
"${COMMAND[@]}" -i "${ignore}" "$(find . -not \( -path ./vendor\* -o -path ./.git\* \))" | ||
} | ||
|
||
cd "${ROOT_DIR}" && check || exit 1 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
cd "${ROOT_DIR}" && check || exit 1 | |
cd "${ROOT_DIR}" | |
update || exit 1 |
hack/update-spelling.sh
Outdated
ignore="$(tr <"${allowed_spelling_words}" '\n' ',')" | ||
"${COMMAND[@]}" -w -i "${ignore}" "$(find . -not \( -path ./vendor\* -o -path ./.git\* \))" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ignore="$(tr <"${allowed_spelling_words}" '\n' ',')" | |
"${COMMAND[@]}" -w -i "${ignore}" "$(find . -not \( -path ./vendor\* -o -path ./.git\* \))" | |
local ignore | |
ignore="$(tr <"${allowed_spelling_words}" '\n' ',')" | |
mapfile -t files < <(find . \( \ | |
-iname "*.md" -o \ | |
-iname "*.sh" -o \ | |
-iname "*.go" -o \ | |
-iname "*.tpl" -o \ | |
-iname "*.yaml" -o \ | |
-iname "*.yml" \ | |
\) \ | |
-not \( \ | |
-path ./.git/\* -o \ | |
-path ./vendor/\* -o \ | |
-path ./demo/node_modules/\* -o \ | |
-path ./site/themes/\* \ | |
\)) | |
"${COMMAND[@]}" -locale US -w -i "${ignore}" "${files[@]}" |
Signed-off-by: yanggang <gang.yang@daocloud.io>
/retest |
pkg/log/logger_ctl.go
Outdated
renderer: fmt.Sprintf("%s%s%s", c, msg, ctc.Reset), | ||
width: stringWidth(msg), | ||
} | ||
} | ||
|
||
var levelColour = map[string]colour{ | ||
var levelColour = map[string]color{ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
var levelColour = map[string]color{ | |
var levelColor = map[string]color{ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
good, why the misspell not found that....😂😂
Signed-off-by: yanggang <gang.yang@daocloud.io>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
/approve
/lgtm
/label tide/merge-method-squash
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: wzshiming, yanggangtony The full list of commands accepted by this bot can be found here. The pull request process is described here
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
What type of PR is this?
/kind feature
What this PR does / why we need it:
Add verify-spelling.sh to check english typos...
Ignore .golangci.yaml,
because importas is the package name.
golinters importas typos
Which issue(s) this PR fixes:
Fixes #545
Special notes for your reviewer:
Does this PR introduce a user-facing change?