CI: convert golangci-lint configuration to v2

This commit is contained in:
Michael Eischer
2025-09-21 21:58:49 +02:00
parent 60d80a6127
commit 8518c1f7d9

View File

@@ -1,70 +1,79 @@
# This is the configuration for golangci-lint for the restic project. version: "2"
#
# A sample config with all settings is here:
# https://github.com/golangci/golangci-lint/blob/master/.golangci.example.yml
linters: linters:
# only enable the linters listed below # only enable the linters listed below
disable-all: true default: none
enable: enable:
# ensure that http response bodies are closed
- bodyclose
# make sure all errors returned by functions are handled # make sure all errors returned by functions are handled
- errcheck - errcheck
# show how code can be simplified
- gosimple
# make sure code is formatted
- gofmt
# examine code and report suspicious constructs, such as Printf calls whose # examine code and report suspicious constructs, such as Printf calls whose
# arguments do not align with the format string # arguments do not align with the format string
- govet - govet
# consistent imports
# make sure names and comments are used according to the conventions - importas
- revive
# detect when assignments to existing variables are not used # detect when assignments to existing variables are not used
- ineffassign - ineffassign
# make sure names and comments are used according to the conventions
- revive
# run static analysis and find errors # run static analysis and find errors
- staticcheck - staticcheck
# find unused variables, functions, structs, types, etc. # find unused variables, functions, structs, types, etc.
- unused - unused
settings:
# parse and typecheck code importas:
- typecheck alias:
- pkg: github.com/restic/restic/internal/test
# ensure that http response bodies are closed alias: rtest
- bodyclose staticcheck:
checks:
- importas # default
- "all"
issues: - "-ST1000"
# don't use the default exclude rules, this hides (among others) ignored - "-ST1003"
# errors from Close() calls - "-ST1016"
exclude-use-default: false - "-ST1020"
- "-ST1021"
# list of things to not warn about - "-ST1022"
exclude: # extra disables
# revive: do not warn about missing comments for exported stuff - "-QF1003"
- exported (function|method|var|type|const) .* should have comment or be unexported - "-QF1008"
# revive: ignore constants in all caps exclusions:
- don't use ALL_CAPS in Go names; use CamelCase generated: lax
# revive: lots of packages don't have such a comment rules:
- "package-comments: should have a package comment" # revive: ignore unused parameters in tests
# staticcheck: there's no easy way to replace these packages - path: (_test\.go|testing\.go|backend/.*/tests\.go)
- "SA1019: \"golang.org/x/crypto/poly1305\" is deprecated" text: "unused-parameter:"
- "SA1019: \"golang.org/x/crypto/openpgp\" is deprecated" # revive: do not warn about missing comments for exported stuff
- "redefines-builtin-id:" - path: (.+)\.go$
text: exported (function|method|var|type|const) .* should have comment or be unexported
exclude-rules: # revive: ignore constants in all caps
# revive: ignore unused parameters in tests - path: (.+)\.go$
- path: (_test\.go|testing\.go|backend/.*/tests\.go) text: don't use ALL_CAPS in Go names; use CamelCase
text: "unused-parameter:" # revive: lots of packages don't have such a comment
- path: (.+)\.go$
linters-settings: text: "package-comments: should have a package comment"
importas: # staticcheck: there's no easy way to replace these packages
alias: - path: (.+)\.go$
- pkg: github.com/restic/restic/internal/test text: 'SA1019: "golang.org/x/crypto/poly1305" is deprecated'
alias: rtest - path: (.+)\.go$
text: 'SA1019: "golang.org/x/crypto/openpgp" is deprecated'
- path: (.+)\.go$
text: "redefines-builtin-id:"
# revive: collection of helpers to implement a backend, more descriptive names would be too repetitive
- path: internal/backend/util/.*.go$
text: "var-naming: avoid meaningless package names"
paths:
- third_party$
- builtin$
- examples$
formatters:
enable:
# make sure code is formatted
- gofmt
exclusions:
generated: lax
paths:
- third_party$
- builtin$
- examples$