Skip to content

Commit 6fcb8e6

Browse files
silverwindearl-warren
authored andcommitted
[gitea] 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. (cherry picked from commit 9c39f85) Conflicts: .github/workflows/pull-compliance.yml Makefile
1 parent 83bb3cf commit 6fcb8e6

File tree

8 files changed

+24
-24
lines changed

8 files changed

+24
-24
lines changed

Makefile

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

137+
SPELLCHECK_FILES := $(GO_DIRS) $(WEB_DIRS) docs/content templates options/locale/locale_en-US.ini .github
138+
137139
GO_SOURCES := $(wildcard *.go)
138140
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)
139141
GO_SOURCES += $(GENERATED_GO_DEST)
@@ -212,6 +214,8 @@ help:
212214
@echo " - lint-swagger lint swagger files"
213215
@echo " - lint-templates lint template files"
214216
@echo " - lint-yaml lint yaml files"
217+
@echo " - lint-spell lint spelling"
218+
@echo " - lint-spell-fix lint spelling and fix issues"
215219
@echo " - checks run various consistency checks"
216220
@echo " - checks-frontend check frontend files"
217221
@echo " - checks-backend check backend files"
@@ -303,10 +307,6 @@ fmt-check: fmt
303307
exit 1; \
304308
fi
305309

306-
.PHONY: misspell-check
307-
misspell-check:
308-
go run $(MISSPELL_PACKAGE) -error $(GO_DIRS) $(WEB_DIRS)
309-
310310
.PHONY: $(TAGS_EVIDENCE)
311311
$(TAGS_EVIDENCE):
312312
@mkdir -p $(MAKE_EVIDENCE_DIR)
@@ -368,10 +368,10 @@ checks: checks-frontend checks-backend
368368
checks-frontend: lockfile-check svg-check
369369

370370
.PHONY: checks-backend
371-
checks-backend: tidy-check swagger-check fmt-check misspell-check forgejo-api-validate swagger-validate security-check
371+
checks-backend: tidy-check swagger-check fmt-check swagger-validate security-check
372372

373373
.PHONY: lint
374-
lint: lint-frontend lint-backend
374+
lint: lint-frontend lint-backend lint-spell
375375

376376
.PHONY: lint-fix
377377
lint-fix: lint-frontend-fix lint-backend-fix
@@ -412,6 +412,14 @@ lint-swagger: node_modules
412412
lint-md: node_modules
413413
npx markdownlint docs *.md
414414

415+
.PHONY: lint-spell
416+
lint-spell:
417+
@go run $(MISSPELL_PACKAGE) -error $(SPELLCHECK_FILES)
418+
419+
.PHONY: lint-spell-fix
420+
lint-spell-fix:
421+
@go run $(MISSPELL_PACKAGE) -w $(SPELLCHECK_FILES)
422+
415423
.PHONY: lint-go
416424
lint-go:
417425
$(GO) run $(GOLANGCI_LINT_PACKAGE) run $(GOLANGCI_LINT_ARGS)

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
@@ -371,7 +371,7 @@
371371
<div class="timeline-item event">
372372
{{if .OriginalAuthor}}
373373
{{else}}
374-
{{/* Some timeline avatars need a offset to correctly allign with their speech
374+
{{/* Some timeline avatars need a offset to correctly align with their speech
375375
bubble. The condition depends on review type and for positive reviews whether
376376
there is a comment element or not */}}
377377
<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)