Skip to content

Commit 9c39f85

Browse files
authored
Rework spellchecking, add lint-spell (go-gitea#29106)
- Use maintained fork https://github.com/golangci/misspell - Rename `mispell-check` to `lint-spell`, add `lint-spell-fix` - Run `lint-spell` in separate actions step - Lint more files, fix discovered issues - Remove inaccurate and outdated info in docs (we do not need GOPATH for tools anymore) Maybe later we can add more spellchecking tools, but I have not found any good ones yet.
1 parent a24e1da commit 9c39f85

File tree

9 files changed

+36
-24
lines changed

9 files changed

+36
-24
lines changed

.github/workflows/pull-compliance.yml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,18 @@ jobs:
6464
- run: make deps-frontend
6565
- run: make lint-swagger
6666

67+
lint-spell:
68+
if: needs.files-changed.outputs.backend == 'true' || needs.files-changed.outputs.frontend == 'true' || needs.files-changed.outputs.actions == 'true' || needs.files-changed.outputs.docs == 'true' || needs.files-changed.outputs.templates == 'true'
69+
needs: files-changed
70+
runs-on: ubuntu-latest
71+
steps:
72+
- uses: actions/checkout@v4
73+
- uses: actions/setup-go@v5
74+
with:
75+
go-version-file: go.mod
76+
check-latest: true
77+
- run: make lint-spell
78+
6779
lint-go-windows:
6880
if: needs.files-changed.outputs.backend == 'true' || needs.files-changed.outputs.actions == 'true'
6981
needs: files-changed

Makefile

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ EDITORCONFIG_CHECKER_PACKAGE ?= github.com/editorconfig-checker/editorconfig-che
3030
GOFUMPT_PACKAGE ?= mvdan.cc/[email protected]
3131
GOLANGCI_LINT_PACKAGE ?= github.com/golangci/golangci-lint/cmd/[email protected]
3232
GXZ_PACKAGE ?= github.com/ulikunitz/xz/cmd/[email protected]
33-
MISSPELL_PACKAGE ?= github.com/client9/misspell/cmd/misspell@v0.3.4
33+
MISSPELL_PACKAGE ?= github.com/golangci/misspell/cmd/misspell@v0.4.1
3434
SWAGGER_PACKAGE ?= github.com/go-swagger/go-swagger/cmd/[email protected]
3535
XGO_PACKAGE ?= src.techknowlogick.com/xgo@latest
3636
GO_LICENSES_PACKAGE ?= github.com/google/[email protected]
@@ -146,6 +146,8 @@ TAR_EXCLUDES := .git data indexers queues log node_modules $(EXECUTABLE) $(FOMAN
146146
GO_DIRS := build cmd models modules routers services tests
147147
WEB_DIRS := web_src/js web_src/css
148148

149+
SPELLCHECK_FILES := $(GO_DIRS) $(WEB_DIRS) docs/content templates options/locale/locale_en-US.ini .github
150+
149151
GO_SOURCES := $(wildcard *.go)
150152
GO_SOURCES += $(shell find $(GO_DIRS) -type f -name "*.go" ! -path modules/options/bindata.go ! -path modules/public/bindata.go ! -path modules/templates/bindata.go)
151153
GO_SOURCES += $(GENERATED_GO_DEST)
@@ -219,6 +221,8 @@ help:
219221
@echo " - lint-swagger lint swagger files"
220222
@echo " - lint-templates lint template files"
221223
@echo " - lint-yaml lint yaml files"
224+
@echo " - lint-spell lint spelling"
225+
@echo " - lint-spell-fix lint spelling and fix issues"
222226
@echo " - checks run various consistency checks"
223227
@echo " - checks-frontend check frontend files"
224228
@echo " - checks-backend check backend files"
@@ -308,10 +312,6 @@ fmt-check: fmt
308312
exit 1; \
309313
fi
310314

311-
.PHONY: misspell-check
312-
misspell-check:
313-
go run $(MISSPELL_PACKAGE) -error $(GO_DIRS) $(WEB_DIRS)
314-
315315
.PHONY: $(TAGS_EVIDENCE)
316316
$(TAGS_EVIDENCE):
317317
@mkdir -p $(MAKE_EVIDENCE_DIR)
@@ -351,10 +351,10 @@ checks: checks-frontend checks-backend
351351
checks-frontend: lockfile-check svg-check
352352

353353
.PHONY: checks-backend
354-
checks-backend: tidy-check swagger-check fmt-check misspell-check swagger-validate security-check
354+
checks-backend: tidy-check swagger-check fmt-check swagger-validate security-check
355355

356356
.PHONY: lint
357-
lint: lint-frontend lint-backend
357+
lint: lint-frontend lint-backend lint-spell
358358

359359
.PHONY: lint-fix
360360
lint-fix: lint-frontend-fix lint-backend-fix
@@ -395,6 +395,14 @@ lint-swagger: node_modules
395395
lint-md: node_modules
396396
npx markdownlint docs *.md
397397

398+
.PHONY: lint-spell
399+
lint-spell:
400+
@go run $(MISSPELL_PACKAGE) -error $(SPELLCHECK_FILES)
401+
402+
.PHONY: lint-spell-fix
403+
lint-spell-fix:
404+
@go run $(MISSPELL_PACKAGE) -w $(SPELLCHECK_FILES)
405+
398406
.PHONY: lint-go
399407
lint-go:
400408
$(GO) run $(GOLANGCI_LINT_PACKAGE) run

docs/content/administration/config-cheat-sheet.zh-cn.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ menu:
2929
[ini](https://github.com/go-ini/ini/#recursive-values) 这里的说明。
3030
标注了 :exclamation: 的配置项表明除非你真的理解这个配置项的意义,否则最好使用默认值。
3131

32-
在下面的默认值中,`$XYZ`代表环境变量`XYZ`的值(详见:`enviroment-to-ini`)。 _`XxYyZz`_是指默认配置的一部分列出的值。这些在 app.ini 文件中不起作用,仅在此处列出作为文档说明。
32+
在下面的默认值中,`$XYZ`代表环境变量`XYZ`的值(详见:`environment-to-ini`)。 _`XxYyZz`_是指默认配置的一部分列出的值。这些在 app.ini 文件中不起作用,仅在此处列出作为文档说明。
3333

3434
包含`#`或者`;`的变量必须使用引号(`` ` ``或者`""""`)包裹,否则会被解析为注释。
3535

docs/content/development/hacking-on-gitea.en-us.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -243,10 +243,10 @@ documentation using:
243243
make generate-swagger
244244
```
245245

246-
You should validate your generated Swagger file and spell-check it with:
246+
You should validate your generated Swagger file:
247247

248248
```bash
249-
make swagger-validate misspell-check
249+
make swagger-validate
250250
```
251251

252252
You should commit the changed swagger JSON file. The continuous integration

docs/content/development/hacking-on-gitea.zh-cn.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -228,10 +228,10 @@ Gitea Logo的 PNG 和 SVG 版本是使用 `TAGS="gitea" make generate-images`
228228
make generate-swagger
229229
```
230230

231-
您应该验证生成的 Swagger 文件并使用以下命令对其进行拼写检查
231+
您应该验证生成的 Swagger 文件
232232

233233
```bash
234-
make swagger-validate misspell-check
234+
make swagger-validate
235235
```
236236

237237
您应该提交更改后的 swagger JSON 文件。持续集成服务器将使用以下方法检查是否已完成:

docs/content/installation/from-source.en-us.md

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -27,13 +27,7 @@ Next, [install Node.js with npm](https://nodejs.org/en/download/) which is
2727
required to build the JavaScript and CSS files. The minimum supported Node.js
2828
version is @minNodeVersion@ and the latest LTS version is recommended.
2929

30-
**Note**: When executing make tasks that require external tools, like
31-
`make misspell-check`, Gitea will automatically download and build these as
32-
necessary. To be able to use these, you must have the `"$GOPATH/bin"` directory
33-
on the executable path. If you don't add the go bin directory to the
34-
executable path, you will have to manage this yourself.
35-
36-
**Note 2**: Go version @minGoVersion@ or higher is required. However, it is recommended to
30+
**Note**: Go version @minGoVersion@ or higher is required. However, it is recommended to
3731
obtain the same version as our continuous integration, see the advice given in
3832
[Hacking on Gitea](development/hacking-on-gitea.md)
3933

docs/content/installation/from-source.zh-cn.md

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,7 @@ menu:
2121

2222
接下来,[安装 Node.js 和 npm](https://nodejs.org/zh-cn/download/), 这是构建 JavaScript 和 CSS 文件所需的。最低支持的 Node.js 版本是 @minNodeVersion@,建议使用最新的 LTS 版本。
2323

24-
**注意**:当执行需要外部工具的 make 任务(如`make misspell-check`)时,Gitea 将根据需要自动下载和构建这些工具。为了能够实现这个目的,你必须将`"$GOPATH/bin"`目录添加到可执行路径中。如果没有将 Go 的二进制目录添加到可执行路径中,你需要自行解决产生的问题。
25-
26-
**注意2**:需要 Go 版本 @minGoVersion@ 或更高版本。不过,建议获取与我们的持续集成(continuous integration, CI)相同的版本,请参阅在 [Hacking on Gitea](development/hacking-on-gitea.md) 中给出的建议。
24+
**注意**:需要 Go 版本 @minGoVersion@ 或更高版本。不过,建议获取与我们的持续集成(continuous integration, CI)相同的版本,请参阅在 [Hacking on Gitea](development/hacking-on-gitea.md) 中给出的建议。
2725

2826
## 下载
2927

templates/repo/branch_dropdown.tmpl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{{/* Attributes:
22
* root
33
* ContainerClasses
4-
* (TODO: search "branch_dropdown" in the template direcotry)
4+
* (TODO: search "branch_dropdown" in the template directory)
55
*/}}
66
{{$defaultSelectedRefName := $.root.BranchName}}
77
{{if and .root.IsViewTag (not .noTag)}}

templates/repo/issue/view_content/comments.tmpl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -367,7 +367,7 @@
367367
<div class="timeline-item event">
368368
{{if .OriginalAuthor}}
369369
{{else}}
370-
{{/* Some timeline avatars need a offset to correctly allign with their speech
370+
{{/* Some timeline avatars need a offset to correctly align with their speech
371371
bubble. The condition depends on review type and for positive reviews whether
372372
there is a comment element or not */}}
373373
<a class="timeline-avatar{{if or (and (eq .Review.Type 1) (or .Content .Attachments)) (and (eq .Review.Type 2) (or .Content .Attachments)) (eq .Review.Type 3)}} timeline-avatar-offset{{end}}"{{if gt .Poster.ID 0}} href="{{.Poster.HomeLink}}"{{end}}>

0 commit comments

Comments
 (0)