Skip to content

spell: turn on pre-commit auto spell checker #1184

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

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 0 additions & 18 deletions .cspell-precommit.json

This file was deleted.

32 changes: 32 additions & 0 deletions .cspell.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
$schema: https://raw.githubusercontent.com/streetsidesoftware/cspell/main/cspell.schema.json
version: 0.2

import:
- "@cspell/dict-golang/cspell-ext.json"
- "@cspell/dict-python/cspell-ext.json"
- "@cspell/dict-lua/cspell-ext.json"
- "@cspell/dict-cpp/cspell-ext.json"
- "@cspell/dict-markdown/cspell-ext.json"
- "@cspell/dict-ru_ru/cspell-ext.json"
- "@cspell/dict-software-terms/cspell-ext.json"

language: "en,ru"

dictionaryDefinitions:
- name: project-words
path: .cspell_project-words.txt
description: Words used in this project
addWords: true

dictionaries:
- project-words
# List of type dependent dictionaries to use with any file types.
- golang
- python
- lua
- cpp

ignoreRegExpList:
- ^\s+(\w+\s+)?"github.com/.*" # Ignore Go import paths.
- -D[A-Z\d_]+ # Ignore CMake flags "-DFLAG_NAME".
- \d+-g[a-f\d]{4,} # Ignore git commit hashes in version string.
94 changes: 57 additions & 37 deletions .cspell_project-words.txt
Original file line number Diff line number Diff line change
@@ -1,48 +1,68 @@
catridge
cli
coredump
distfiles
dpkg
etcdctl
*cmd*
+cli
+ctl
+s
addfinalizer
aeon*
autoexpel
bootstrapper
ccluster
clientv3
clustercmd
commentf
containsf
debugf
demoter
disbalance
distfile*
drwxr
equalf
errf
etcd*
etcdserver
evaler
getenv
falsef
finalizer*
flightrec
getfixturevalue
golangci
Infof
iproto
isort
logfile
incdir
infof
leaderuuid
libcluster
luabody
luajit
luakit
luarocks
MAKEFLAGS
mapstructure
memtx
myapp
packignore
pidfile
postinst
preinst
mvcc
mvccpb
nilf
nodeps
nogc
nolint
notarantool
promptui
protoc
pytest
rebootstrap
replicaset
replicasets
rocks
rockspec
replicaset*
rockspec*
rpmdeb
specialchars
sslcafile
sslcertfile
sslciphers
sslkeyfile
stateboard
Svacer
tarantool
tarantoolctl
tarantools
tcm
testdata
testfull
TNTP
ttable
venv
svacer
tarantool*
tlsdialer
tmpl
tnt+
tntp
trimprefix
truef
vshard
Warnf
xlog
xlogs
vylog
warnf
xcall
xlog*
12 changes: 6 additions & 6 deletions .github/actions/static-code-check/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,12 @@ runs:
echo "Found base branch with hash: '${HASH}'"
echo "BASE_BRANCH=${HASH}" >> ${GITHUB_ENV}

- name: pre-commit checks (diff)
uses: pre-commit/[email protected]
env:
SKIP: golangci-lint-full
with:
extra_args: --all-files --from-ref=${{ env.BASE_BRANCH }} --to-ref=HEAD --hook-stage=manual
# - name: pre-commit checks (diff)
# uses: pre-commit/[email protected]
# env:
# SKIP: golangci-lint-full
# with:
# extra_args: --all-files --from-ref=${{ env.BASE_BRANCH }} --to-ref=HEAD --hook-stage=manual

- name: pre-commit checks (full)
uses: pre-commit/[email protected]
Expand Down
72 changes: 32 additions & 40 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -23,47 +23,40 @@ repos:
files: ".cspell_project-words.txt"
args: [--ignore-case, --unique]

- repo: https://github.com/codespell-project/codespell
rev: v2.4.1
hooks:
- id: codespell
name: "Check for common misspellings"
stages: [pre-commit, manual]
types_or: [go, python, lua]
additional_dependencies:
- tomli

- repo: https://github.com/streetsidesoftware/cspell-cli
rev: v9.0.1
rev: v9.1.0
hooks:
- id: cspell
name: "Spell-checking documentation files"
stages: [pre-commit, manual]
args:
[--config=.cspell-precommit.json, --show-context, --show-suggestions]
types_or: [markdown]
name: "Spell checking commit message"
stages: [commit-msg]
args: [--config=.cspell.yaml, --show-context, --show-suggestions]
additional_dependencies:
- "@cspell/dict-markdown"
- "@cspell/dict-ru_ru"
- "@cspell/dict-golang"
- "@cspell/dict-python"
- "@cspell/dict-lua"
- "@cspell/dict-cpp"
- "@cspell/dict-software-terms"

- id: cspell
name: "Spell-checking commit message"
stages: [commit-msg]
args:
[--config=.cspell-precommit.json, --show-context, --show-suggestions]
name: "Spell checking source files"
stages: [pre-commit, manual]
args: [--config=.cspell.yaml, --show-context, --show-suggestions]
types_or: [go, python, markdown]
exclude: |
(?x)^(
.*\.pb.go|
.*/third_party/.*
)$
additional_dependencies:
- "@cspell/dict-markdown"
- "@cspell/dict-ru_ru"
# TODO: add words from [.go, .py] with "errors" to `.cspell_project-words.txt` (#TNTP-3105).
# - id: cspell
# name: "Py: Spell check files"
# types: [python]
# additional_dependencies:
# - "@cspell/dict-python"
# - id: cspell
# name: "Go: Spell check files"
# types: [go]
# additional_dependencies:
# - "@cspell/dict-golang"
- "@cspell/dict-golang"
- "@cspell/dict-python"
- "@cspell/dict-lua"
- "@cspell/dict-cpp"
- "@cspell/dict-software-terms"

- repo: local
hooks:
Expand All @@ -88,7 +81,7 @@ repos:
args: [--max-len=100, --tab-len=4, --no-reformat-tags]

- repo: https://github.com/golangci/golangci-lint
rev: v2.1.6
rev: v2.2.2
hooks:
- id: golangci-lint
name: "Go: verify sources"
Expand All @@ -102,7 +95,6 @@ repos:
- id: golangci-lint-full
name: "Go: verify all sources (CI)"
description: Checking all Go sources.
pass_filenames: false
always_run: true
stages: [manual]
args: [--config=golint-precommit-ci.yml, --allow-parallel-runners]
Expand All @@ -113,8 +105,8 @@ repos:
language: golang
types: [go]
name: "Go: verify sources diff (CI)"
description: Checking only fresh changes, added to the PR.
stages: [manual]
pass_filenames: false
always_run: true
entry: >-
bash -c "golangci-lint run --new-from-rev=${BASE_BRANCH:-master}
Expand All @@ -123,16 +115,16 @@ repos:
- github.com/golangci/golangci-lint/v2/cmd/[email protected]

- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.12.0
rev: v0.12.2
hooks:
- id: ruff-check
name: "Py: Run the linter"
args: [--fix]
- id: ruff-format
name: "Py: Run the formatter"
stages: [pre-commit, manual]
files: test/.*\.py$

- id: ruff-format
name: "Py: Run the formatter"
- id: ruff-check
name: "Py: Run the linter"
args: [--fix]
stages: [pre-commit, manual]
files: test/.*\.py$

Expand Down
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -781,7 +781,7 @@ Additionally, several fixes were implemented to improve stability.

### Changed

- Modules `tt start`, `tt connect` and `tt catridge` now use relative
- Modules `tt start`, `tt connect` and `tt cartridge` now use relative
paths for unix sockets. It allows to use socket paths longer than sun_path
limit.(108/106 on linux/macOS) e.g foo/bar.sock -> ./bar.sock

Expand Down
3 changes: 3 additions & 0 deletions cli/binary/switch.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,13 @@ type SwitchCtx struct {
Version string
}

// spell-checker:disable
// ansi is a string to clean strings from ANSI escape codes using regexp.
const ansi = "[\u001B\u009B][[\\]()#;?]*(?:(?:(?:[a-zA-Z\\d]*(?:;" +
"[a-zA-Z\\d]*)*)?\u0007)|(?:(?:\\d{1,4}(?:;\\d{0,4})*)?[\\dA-PRZcf-ntqry=><~]))"

// spell-checker:enable

func cleanString(str string) string {
re := regexp.MustCompile(ansi)
return re.ReplaceAllString(str, "")
Expand Down
10 changes: 5 additions & 5 deletions cli/checkpoint/checkpoint.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,9 @@ func Cat(tntCli cmdcontext.TarantoolCli) error {
// Play is playing the contents of .snap/.xlog files to another Tarantool instance.
// Returns an error if such occur during playing.
func Play(tntCli cmdcontext.TarantoolCli) error {
var errbuff bytes.Buffer
var errBuff bytes.Buffer
cmd := exec.Command(tntCli.Executable, "-")
cmd.Stderr = &errbuff
cmd.Stderr = &errBuff

stdoutPipe, err := cmd.StdoutPipe()
if err != nil {
Expand All @@ -63,7 +63,7 @@ func Play(tntCli cmdcontext.TarantoolCli) error {
stdinPipe.Close()

if err := cmd.Start(); err != nil {
return fmt.Errorf("result of play: %s", errbuff.String())
return fmt.Errorf("result of play: %s", errBuff.String())
}

scanner := bufio.NewScanner(stdoutPipe)
Expand All @@ -73,8 +73,8 @@ func Play(tntCli cmdcontext.TarantoolCli) error {
}
cmd.Wait()

if len(errbuff.String()) > 0 {
return fmt.Errorf("result of play: %s", errbuff.String())
if len(errBuff.String()) > 0 {
return fmt.Errorf("result of play: %s", errBuff.String())
}

return nil
Expand Down
2 changes: 1 addition & 1 deletion cli/cluster/cmd/publish.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import (
"github.com/tarantool/tt/lib/connect"
)

// PublishCtx contains information abould cluster publish command execution
// PublishCtx contains information about cluster publish command execution
// context.
type PublishCtx struct {
// Username defines a username for connection.
Expand Down
Loading
Loading