Skip to content

Commit

Permalink
Merge pull request #29 from mudclient/style/lint
Browse files Browse the repository at this point in the history
排版和重构代码,以提升代码质量
  • Loading branch information
dzpao authored Feb 11, 2020
2 parents 7e74b49 + ed5ae3f commit 5985209
Show file tree
Hide file tree
Showing 10 changed files with 445 additions and 410 deletions.
3 changes: 3 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,3 +25,6 @@ jobs:

- name: Build
run: go build -v .

- name: Lint
run: docker run --rm -v $(pwd):/app -w /app golangci/golangci-lint:v1.23.3 golangci-lint run -v ./...
30 changes: 30 additions & 0 deletions .golangci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
service:
golangci-lint-version: 1.23.x
prepare:
- go mod tidy
- go generate ./...

linters:
enable-all: true
disable:
# 因为只有两行语句的 case 语句里面强制要求 return 语句换行会让整个 switch 很分裂。
- wsl
# 因为连 1 都算 magic number 的话,许多循环就没法写了。
# https://github.com/tommy-muehle/go-mnd/issues/3
- gomnd
# 有些情况下错误不可避免:
# https://github.com/alexkohler/dogsled/issues/2
- dogsled
# V1.0 之前有 TODO/FIXME 很正常吧。
- godox
# 有些情况下错误不可避免:
# https://github.com/mvdan/unparam/issues/43
- unparam
# 下面这两个 checker 太过激进,并不认同
- gochecknoglobals
- gochecknoinits

linters-settings:
errcheck:
check-type-assertions: true
ignore: '[FS]?[Pp]rint(|f|ln)|Write'
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,12 @@
</a>
<a href="https://github.com/mudclient/go-mud/actions?workflow=Build">
<img alt="Build workflow" src="https://github.com/mudclient/go-mud/workflows/Build/badge.svg">
</a>
<a href="https://goreportcard.com/report/github.com/mudclient/go-mud">
<img alt="Go Report" src="https://goreportcard.com/badge/github.com/mudclient/go-mud">
</a>
<a href="https://golangci.com/r/github.com/mudclient/go-mud">
<img alt="GolangCI Report" src="https://github.com/golangci/golangci-web/blob/master/src/assets/images/badge_a_plus_flat.svg">
</a>
</p>
</p>
Expand Down
Loading

0 comments on commit 5985209

Please sign in to comment.