fix: linter

This commit is contained in:
2023-04-21 12:05:30 +08:00
parent 53ab00c196
commit 96f4181e5f
2 changed files with 300 additions and 341 deletions
+20 -64
View File
@@ -5,12 +5,12 @@ linters:
enable:
- govet
- staticcheck
- unused
- ineffassign
- typecheck
- exportloopref
- bodyclose
- gofmt
- gosimple
- stylecheck
- revive
- errorlint # finds code that will cause problems with the error wrapping scheme introduced in Go 1.13
@@ -19,6 +19,18 @@ linters:
staticcheck:
# SAxxxx checks in https://staticcheck.io/docs/configuration/options/#checks
checks: ["all"]
stylecheck:
checks:
[
"all",
"-ST1000",
"-ST1001",
"-ST1003",
"-ST1016",
"-ST1020",
"-ST1021",
"-ST1022",
]
revive:
# Maximum number of open files at the same time.
# See https://github.com/mgechev/revive#command-line-flags
@@ -40,15 +52,6 @@ linters:
# Default: 0.8
confidence: 0.1
rules:
# https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#add-constant
- name: add-constant
severity: warning
disabled: false
arguments:
- maxLitCount: "3"
allowStrs: '""'
allowInts: "0,1,2"
allowFloats: "0.0,0.,1.0,1.,2.0,2."
# https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#argument-limit
- name: argument-limit
severity: warning
@@ -63,14 +66,6 @@ linters:
severity: warning
disabled: false
arguments: ["Ω", "Σ", "σ", "7"]
# https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#bare-return
- name: bare-return
severity: warning
disabled: false
# https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#blank-imports
- name: blank-imports
severity: warning
disabled: false
# https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#bool-literal-in-expr
- name: bool-literal-in-expr
severity: warning
@@ -108,7 +103,7 @@ linters:
- name: cyclomatic
severity: warning
disabled: false
arguments: [3]
arguments: [5]
# https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#datarace
- name: datarace
severity: warning
@@ -123,10 +118,6 @@ linters:
disabled: false
arguments:
- ["call-chain", "loop"]
# https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#dot-imports
- name: dot-imports
severity: warning
disabled: false
# https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#duplicated-imports
- name: duplicated-imports
severity: warning
@@ -135,14 +126,6 @@ linters:
- name: early-return
severity: warning
disabled: false
# https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#empty-block
- name: empty-block
severity: warning
disabled: false
# https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#empty-lines
- name: empty-lines
severity: warning
disabled: false
# https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#error-naming
- name: error-naming
severity: warning
@@ -166,12 +149,6 @@ linters:
arguments:
- "checkPrivateReceivers"
- "sayRepetitiveInsteadOfStutters"
# https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#file-header
- name: file-header
severity: warning
disabled: false
arguments:
- This is the text that must appear at the top of source files.
# https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#flag-parameter
- name: flag-parameter
severity: warning
@@ -185,7 +162,7 @@ linters:
- name: function-length
severity: warning
disabled: false
arguments: [10, 0]
arguments: [100, 0]
# https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#get-return
- name: get-return
severity: warning
@@ -213,20 +190,6 @@ linters:
arguments:
- "crypto/md5"
- "crypto/sha1"
# https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#import-shadowing
- name: import-shadowing
severity: warning
disabled: false
# https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#line-length-limit
- name: line-length-limit
severity: warning
disabled: false
arguments: [80]
# https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#max-public-structs
- name: max-public-structs
severity: warning
disabled: false
arguments: [3]
# https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#modifies-parameter
- name: modifies-parameter
severity: warning
@@ -276,10 +239,10 @@ linters:
severity: warning
disabled: false
arguments:
- - 'core.WriteError[1].Message'
- '/^([^A-Z]|$)/'
- - "core.WriteError[1].Message"
- "/^([^A-Z]|$)/"
- must not start with a capital letter
- - 'fmt.Errorf[0]'
- - "fmt.Errorf[0]"
- '/(^|[^\.!?])$/'
- must not end in punctuation
- - panic
@@ -329,7 +292,8 @@ linters:
disabled: false
arguments:
- "fmt.Printf"
- "myFunction"
- "os.(Create|WriteFile|Chmod)"
- "net.*"
# https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#unnecessary-stmt
- name: unnecessary-stmt
severity: warning
@@ -338,14 +302,6 @@ linters:
- name: unreachable-code
severity: warning
disabled: false
# https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#unused-parameter
- name: unused-parameter
severity: warning
disabled: false
# https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#unused-receiver
- name: unused-receiver
severity: warning
disabled: false
# https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#useless-break
- name: useless-break
severity: warning
+4 -1
View File
@@ -145,6 +145,9 @@ alias gitb="git branch --show-current | tr -d '\n' | pbcopy"
alias gci="golangci-lint run -c=~/.dotfile/.golangci.yml ./..."
alias gmt="go mod tidy"
alias gtc="go test -gcflags=all=-l -cover ./..."
alias gtr="(){go test -gcflags=all=-l -v -run $1. ;}"
alias swg="swag init -o docs -g "
alias sws="swagger serve -F=swagger"
function gtr(){
go test -gcflags=all=-l -v -run="$1"
}