Skip to content

Commit

Permalink
ci: adjust lint
Browse files Browse the repository at this point in the history
Signed-off-by: thxCode <thxcode0824@gmail.com>
  • Loading branch information
thxCode committed Feb 4, 2024
1 parent 4ebaab4 commit 7d2d3f2
Show file tree
Hide file tree
Showing 9 changed files with 136 additions and 268 deletions.
123 changes: 74 additions & 49 deletions .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -44,16 +44,16 @@ linters:
- exportloopref
- godot
- goconst
- gofumpt
- gocritic
- gosimple
- gosec
- govet
- gofumpt
- gofmt
- ineffassign
- lll
- makezero
- misspell
- misspell
- nakedret
- nilerr
- prealloc
Expand All @@ -67,6 +67,7 @@ linters:
- unused
- usestdlibvars
- whitespace
- wsl

# enable complexity linters
# - dupl
Expand All @@ -75,24 +76,20 @@ linters:
# - funlen

linters-settings:
staticcheck:
checks: ["all", "-SA1019", "-SA2002"]
stylecheck:
checks: ["all", "-ST1003"]
gosec:
severity: "low"
confidence: "low"
excludes:
- G101
- G107
- G112
- G404
revive:
rules:
- name: var-naming
disabled: true
arguments:
- ["HTTP", "ID", "TLS", "TCP", "UDP", "API", "CA", "URL", "DNS"]
decorder:
dec-order:
- const
- var
- func
disable-init-func-first-check: false
disable-dec-order-check: true
errorlint:
# Check whether fmt.Errorf uses the %w verb for formatting errors. See the readme for caveats
errorf: true
# Check for plain type assertions and type switches
asserts: true
# Check for plain error comparisons
comparison: true
godot:
# Comments to be checked: `declarations`, `toplevel`, or `all`.
# Default: declarations
Expand All @@ -110,24 +107,65 @@ linters-settings:
# Check that each sentence starts with a capital letter.
# Default: false
capital: true
lll:
# max line length, lines longer will be reported. Default is 120.
# '\t' is counted as 1 character by default, and can be changed with the tab-width option
line-length: 150
# tab width in spaces. Default to 1.
tab-width: 1
goconst:
# Minimal length of string constant.
# Default: 3
min-len: 3
# Minimum occurrences of constant string count to trigger issue.
# Default: 3
min-occurrences: 3
min-occurrences: 10
gosimple:
go: "1.21"
checks: [ "all" ]
gosec:
severity: "low"
confidence: "low"
excludes:
- G101
- G107
- G112
- G404
gofumpt:
# Choose whether to use the extra rules.
# Default: false
extra-rules: true
gofmt:
# Simplify code: gofmt with `-s` option.
# Default: true
simplify: true
# Apply the rewrite rules to the source before reformatting.
# https://pkg.go.dev/cmd/gofmt
# Default: []
rewrite-rules:
- pattern: 'interface{}'
replacement: 'any'
- pattern: 'a[b:len(a)]'
replacement: 'a[b:]'
lll:
# max line length, lines longer will be reported. Default is 120.
# '\t' is counted as 1 character by default, and can be changed with the tab-width option
line-length: 150
# tab width in spaces. Default to 1.
tab-width: 1
makezero:
always: false
misspell:
# Correct spellings using locale preferences for US or UK.
# Default is to use a neutral variety of English.
# Setting locale to US will correct the British spelling of 'colour' to 'color'.
locale: US
nakedret:
max-func-lines: 60
revive:
rules:
- name: var-naming
disabled: true
arguments:
- [ "HTTP", "ID", "TLS", "TCP", "UDP", "API", "CA", "URL", "DNS" ]
staticcheck:
checks: [ "all", "-SA1019", "-SA2002", "-SA5008" ]
stylecheck:
checks: [ "all", "-ST1003" ]
unparam:
# Inspect exported functions, default is false. Set to true if no external program/library imports your code.
# XXX: if you enable this setting, unparam will report a lot of false-positives in text editors:
Expand Down Expand Up @@ -156,20 +194,6 @@ linters-settings:
# Mark all identifiers inside generated files as used.
# Default: true
generated-is-used: true
errorlint:
# Check whether fmt.Errorf uses the %w verb for formatting errors. See the readme for caveats
errorf: true
# Check for plain type assertions and type switches
asserts: true
# Check for plain error comparisons
comparison: true
makezero:
always: false
gosimple:
go: "1.20"
checks: ["all"]
nakedret:
max-func-lines: 60
usestdlibvars:
# Suggest the use of http.MethodXX
# Default: true
Expand All @@ -189,13 +213,15 @@ linters-settings:
# Suggest the use of crypto.Hash
# Default: false
crypto-hash: true
decorder:
dec-order:
- const
- var
- func
disable-init-func-first-check: false
disable-dec-order-check: true
wsl:
# Allows assignments to be cuddled with anything.
allow-assign-and-anything: true
# Allow blocks to end with comments.
allow-trailing-comment: true
# Causes an error if a short declaration (:=) cuddles with anything other than
# another short declaration.
# This logic overrides force-err-cuddling among others.
force-short-decl-cuddling: false

issues:
exclude-rules:
Expand All @@ -207,4 +233,3 @@ issues:
- makezero
- lll
- funlen
- wsl
Loading

0 comments on commit 7d2d3f2

Please sign in to comment.