refactor(.golangci.yaml): Update linters and config for Go code analysis

Signed-off-by: yxxhero <aiopsclub@163.com>
This commit is contained in:
yxxhero 2025-02-18 07:55:56 +08:00
parent a89803521d
commit 1bb3452366
2 changed files with 12 additions and 27 deletions

View File

@ -20,7 +20,7 @@ jobs:
cache: false
- uses: golangci/golangci-lint-action@v6
with:
version: v1.61.0
version: v1.64.5
tests:
runs-on: ubuntu-latest

View File

@ -27,10 +27,6 @@ run:
# - src/external_libs
# - autogenerated_by_my_lib
# default is true. Enables skipping of directories:
# vendor$, third_party$, testdata$, examples$, Godeps$, builtin$
skip-dirs-use-default: true
# which files to skip: they will be analyzed, but issues from them
# won't be reported. Default value is empty list, but there is
# no need to include all autogenerated files, we confidently recognize
@ -52,7 +48,9 @@ run:
# output configuration options
output:
# colored-line-number|line-number|json|tab|checkstyle|code-climate, default is "colored-line-number"
format: line-number
formats:
- format: line-number
path: stdout
# print lines of code with issue, default is true
print-issued-lines: true
@ -88,12 +86,13 @@ linters-settings:
# Disable error checking, as errorcheck detects more errors and is more configurable.
gosec:
exclude:
excludes:
- "G104"
govet:
# report about shadowed variables
check-shadowing: false
disable:
- shadow
# settings per analyzer
settings:
@ -111,25 +110,20 @@ linters-settings:
# disable:
# - shadow
# disable-all: false
golint:
revive:
# minimal confidence for issues, default is 0.8
min-confidence: 0.8
confidence: 0.8
ignore-generated-header: true
severity: warning
gofmt:
# simplify code: gofmt with `-s` option, true by default
simplify: true
goimports:
# put imports beginning with prefix after 3rd-party packages;
# it's a comma-separated list of prefixes
# local-prefixes: github.com/org/project
gocyclo:
# minimal code complexity to report, 30 by default (but we recommend 10-20)
min-complexity: 30
gocognit:
# minimal code complexity to report, 30 by default (but we recommend 10-20)
min-complexity: 100
maligned:
# print struct with more effective memory layout or not, false by default
suggest-new: true
dupl:
# tokens count to trigger issue, 150 by default
threshold: 100
@ -159,12 +153,6 @@ linters-settings:
line-length: 120
# tab width in spaces. Default to 1.
tab-width: 1
unused:
# treat code as a program (not a library) and report unused exported identifiers; default is false.
# XXX: if you enable this setting, unused will report a lot of false-positives in text editors:
# if it's called for subdir of a project it can't find funcs usages. All text editor integrations
# with golangci-lint call it on a directory with the changed file.
check-exported: false
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:
@ -237,9 +225,6 @@ linters-settings:
allow-trailing-comment: false
# Force newlines in end of case at this limit (0 = never).
force-case-trailing-whitespace: 0
revive:
ignore-generated-header: true
severity: warning
funlen:
# Checks the number of lines in a function.
# If lower than 0, disable the check.