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 cache: false
- uses: golangci/golangci-lint-action@v6 - uses: golangci/golangci-lint-action@v6
with: with:
version: v1.61.0 version: v1.64.5
tests: tests:
runs-on: ubuntu-latest runs-on: ubuntu-latest

View File

@ -27,10 +27,6 @@ run:
# - src/external_libs # - src/external_libs
# - autogenerated_by_my_lib # - 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 # which files to skip: they will be analyzed, but issues from them
# won't be reported. Default value is empty list, but there is # won't be reported. Default value is empty list, but there is
# no need to include all autogenerated files, we confidently recognize # no need to include all autogenerated files, we confidently recognize
@ -52,7 +48,9 @@ run:
# output configuration options # output configuration options
output: output:
# colored-line-number|line-number|json|tab|checkstyle|code-climate, default is "colored-line-number" # 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 lines of code with issue, default is true
print-issued-lines: true print-issued-lines: true
@ -88,12 +86,13 @@ linters-settings:
# Disable error checking, as errorcheck detects more errors and is more configurable. # Disable error checking, as errorcheck detects more errors and is more configurable.
gosec: gosec:
exclude: excludes:
- "G104" - "G104"
govet: govet:
# report about shadowed variables # report about shadowed variables
check-shadowing: false disable:
- shadow
# settings per analyzer # settings per analyzer
settings: settings:
@ -111,25 +110,20 @@ linters-settings:
# disable: # disable:
# - shadow # - shadow
# disable-all: false # disable-all: false
golint: revive:
# minimal confidence for issues, default is 0.8 # minimal confidence for issues, default is 0.8
min-confidence: 0.8 confidence: 0.8
ignore-generated-header: true
severity: warning
gofmt: gofmt:
# simplify code: gofmt with `-s` option, true by default # simplify code: gofmt with `-s` option, true by default
simplify: true 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: gocyclo:
# minimal code complexity to report, 30 by default (but we recommend 10-20) # minimal code complexity to report, 30 by default (but we recommend 10-20)
min-complexity: 30 min-complexity: 30
gocognit: gocognit:
# minimal code complexity to report, 30 by default (but we recommend 10-20) # minimal code complexity to report, 30 by default (but we recommend 10-20)
min-complexity: 100 min-complexity: 100
maligned:
# print struct with more effective memory layout or not, false by default
suggest-new: true
dupl: dupl:
# tokens count to trigger issue, 150 by default # tokens count to trigger issue, 150 by default
threshold: 100 threshold: 100
@ -159,12 +153,6 @@ linters-settings:
line-length: 120 line-length: 120
# tab width in spaces. Default to 1. # tab width in spaces. Default to 1.
tab-width: 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: unparam:
# Inspect exported functions, default is false. Set to true if no external program/library imports your code. # 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: # 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 allow-trailing-comment: false
# Force newlines in end of case at this limit (0 = never). # Force newlines in end of case at this limit (0 = never).
force-case-trailing-whitespace: 0 force-case-trailing-whitespace: 0
revive:
ignore-generated-header: true
severity: warning
funlen: funlen:
# Checks the number of lines in a function. # Checks the number of lines in a function.
# If lower than 0, disable the check. # If lower than 0, disable the check.