mirror of
https://github.com/moby/moby.git
synced 2022-11-09 12:21:53 -05:00
golangci-lint: update to v1.49.0
Remove the "deadcode", "structcheck", and "varcheck" linters, as they are
deprecated:
WARN [runner] The linter 'deadcode' is deprecated (since v1.49.0) due to: The owner seems to have abandoned the linter. Replaced by unused.
WARN [runner] The linter 'structcheck' is deprecated (since v1.49.0) due to: The owner seems to have abandoned the linter. Replaced by unused.
WARN [runner] The linter 'varcheck' is deprecated (since v1.49.0) due to: The owner seems to have abandoned the linter. Replaced by unused.
WARN [linters context] structcheck is disabled because of generics. You can track the evolution of the generics support by following the https://github.com/golangci/golangci-lint/issues/2649.
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
(cherry picked from commit 2f1c382a6d
)
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
This commit is contained in:
parent
7772535e79
commit
3ce520ec80
8 changed files with 35 additions and 37 deletions
|
@ -202,7 +202,8 @@ RUN --mount=type=cache,target=/root/.cache/go-build \
|
||||||
PREFIX=/build /install.sh containerd
|
PREFIX=/build /install.sh containerd
|
||||||
|
|
||||||
FROM base AS golangci_lint
|
FROM base AS golangci_lint
|
||||||
ARG GOLANGCI_LINT_VERSION=v1.46.2
|
# FIXME: when updating golangci-lint, remove the temporary "nolint" in https://github.com/moby/moby/blob/7860686a8df15eea9def9e6189c6f9eca031bb6f/libnetwork/networkdb/cluster.go#L246
|
||||||
|
ARG GOLANGCI_LINT_VERSION=v1.49.0
|
||||||
RUN --mount=type=cache,target=/root/.cache/go-build \
|
RUN --mount=type=cache,target=/root/.cache/go-build \
|
||||||
--mount=type=cache,target=/go/pkg/mod \
|
--mount=type=cache,target=/go/pkg/mod \
|
||||||
GOBIN=/build/ GO111MODULE=on go install "github.com/golangci/golangci-lint/cmd/golangci-lint@${GOLANGCI_LINT_VERSION}" \
|
GOBIN=/build/ GO111MODULE=on go install "github.com/golangci/golangci-lint/cmd/golangci-lint@${GOLANGCI_LINT_VERSION}" \
|
||||||
|
|
|
@ -5,7 +5,6 @@ import (
|
||||||
"github.com/sirupsen/logrus"
|
"github.com/sirupsen/logrus"
|
||||||
)
|
)
|
||||||
|
|
||||||
//nolint:structcheck
|
|
||||||
type driverQuota struct {
|
type driverQuota struct {
|
||||||
quotaCtl *quota.Control
|
quotaCtl *quota.Control
|
||||||
quotaOpt quota.Quota
|
quotaOpt quota.Quota
|
||||||
|
|
|
@ -1,6 +1,5 @@
|
||||||
linters:
|
linters:
|
||||||
enable:
|
enable:
|
||||||
- deadcode
|
|
||||||
- depguard
|
- depguard
|
||||||
- goimports
|
- goimports
|
||||||
- gosec
|
- gosec
|
||||||
|
@ -10,11 +9,9 @@ linters:
|
||||||
- misspell
|
- misspell
|
||||||
- revive
|
- revive
|
||||||
- staticcheck
|
- staticcheck
|
||||||
- structcheck
|
|
||||||
- typecheck
|
- typecheck
|
||||||
- unconvert
|
- unconvert
|
||||||
- unused
|
- unused
|
||||||
- varcheck
|
|
||||||
|
|
||||||
disable:
|
disable:
|
||||||
- errcheck
|
- errcheck
|
||||||
|
@ -36,6 +33,11 @@ linters-settings:
|
||||||
# The io/ioutil package has been deprecated.
|
# The io/ioutil package has been deprecated.
|
||||||
# https://go.dev/doc/go1.16#ioutil
|
# https://go.dev/doc/go1.16#ioutil
|
||||||
- io/ioutil
|
- io/ioutil
|
||||||
|
revive:
|
||||||
|
rules:
|
||||||
|
# FIXME make sure all packages have a description. Currently, there's many packages without.
|
||||||
|
- name: package-comments
|
||||||
|
disabled: true
|
||||||
issues:
|
issues:
|
||||||
# The default exclusion rules are a bit too permissive, so copying the relevant ones below
|
# The default exclusion rules are a bit too permissive, so copying the relevant ones below
|
||||||
exclude-use-default: false
|
exclude-use-default: false
|
||||||
|
@ -111,19 +113,6 @@ issues:
|
||||||
- text: "SA1019: httputil.ErrPersistEOF"
|
- text: "SA1019: httputil.ErrPersistEOF"
|
||||||
linters:
|
linters:
|
||||||
- staticcheck
|
- staticcheck
|
||||||
# This code is doing some fun stuff with reflect and it trips up the linter.
|
|
||||||
- text: "field `foo` is unused"
|
|
||||||
path: "libnetwork/options/options_test.go"
|
|
||||||
linters:
|
|
||||||
- structcheck
|
|
||||||
- unused
|
|
||||||
# This field is only used on windows but is defined in a platform agnostic file.
|
|
||||||
# The linter doesn't understand that the field is used.
|
|
||||||
- text: "`resolverOnce` is unused"
|
|
||||||
path: libnetwork/network.go
|
|
||||||
linters:
|
|
||||||
- structcheck
|
|
||||||
- unused
|
|
||||||
|
|
||||||
# Maximum issues count per one linter. Set to 0 to disable. Default is 50.
|
# Maximum issues count per one linter. Set to 0 to disable. Default is 50.
|
||||||
max-issues-per-linter: 0
|
max-issues-per-linter: 0
|
||||||
|
|
|
@ -222,7 +222,7 @@ type network struct {
|
||||||
dbExists bool
|
dbExists bool
|
||||||
persist bool
|
persist bool
|
||||||
drvOnce *sync.Once
|
drvOnce *sync.Once
|
||||||
resolverOnce sync.Once
|
resolverOnce sync.Once //nolint:nolintlint,unused // only used on windows
|
||||||
resolver []Resolver
|
resolver []Resolver
|
||||||
internal bool
|
internal bool
|
||||||
attachable bool
|
attachable bool
|
||||||
|
|
|
@ -78,18 +78,24 @@ func TestGenerateMissingField(t *testing.T) {
|
||||||
|
|
||||||
if _, ok := err.(NoSuchFieldError); !ok {
|
if _, ok := err.(NoSuchFieldError); !ok {
|
||||||
t.Fatalf("expected NoSuchFieldError, got %#v", err)
|
t.Fatalf("expected NoSuchFieldError, got %#v", err)
|
||||||
} else if expected := "no field"; !strings.Contains(err.Error(), expected) {
|
}
|
||||||
|
|
||||||
|
const expected = "no field"
|
||||||
|
if !strings.Contains(err.Error(), expected) {
|
||||||
t.Fatalf("expected %q in error message, got %s", expected, err.Error())
|
t.Fatalf("expected %q in error message, got %s", expected, err.Error())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestFieldCannotBeSet(t *testing.T) {
|
func TestFieldCannotBeSet(t *testing.T) {
|
||||||
type Model struct{ foo int } //nolint:structcheck
|
type Model struct{ foo int } //nolint:nolintlint,unused // un-exported field is used to test error-handling
|
||||||
_, err := GenerateFromModel(Generic{"foo": "bar"}, Model{})
|
_, err := GenerateFromModel(Generic{"foo": "bar"}, Model{})
|
||||||
|
|
||||||
if _, ok := err.(CannotSetFieldError); !ok {
|
if _, ok := err.(CannotSetFieldError); !ok {
|
||||||
t.Fatalf("expected CannotSetFieldError, got %#v", err)
|
t.Fatalf("expected CannotSetFieldError, got %#v", err)
|
||||||
} else if expected := "cannot set field"; !strings.Contains(err.Error(), expected) {
|
}
|
||||||
|
|
||||||
|
const expected = "cannot set field"
|
||||||
|
if !strings.Contains(err.Error(), expected) {
|
||||||
t.Fatalf("expected %q in error message, got %s", expected, err.Error())
|
t.Fatalf("expected %q in error message, got %s", expected, err.Error())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -100,7 +106,10 @@ func TestTypeMismatchError(t *testing.T) {
|
||||||
|
|
||||||
if _, ok := err.(TypeMismatchError); !ok {
|
if _, ok := err.(TypeMismatchError); !ok {
|
||||||
t.Fatalf("expected TypeMismatchError, got %#v", err)
|
t.Fatalf("expected TypeMismatchError, got %#v", err)
|
||||||
} else if expected := "type mismatch"; !strings.Contains(err.Error(), expected) {
|
}
|
||||||
|
|
||||||
|
const expected = "type mismatch"
|
||||||
|
if !strings.Contains(err.Error(), expected) {
|
||||||
t.Fatalf("expected %q in error message, got %s", expected, err.Error())
|
t.Fatalf("expected %q in error message, got %s", expected, err.Error())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -93,12 +93,12 @@ type sandbox struct {
|
||||||
// These are the container configs used to customize container /etc/hosts file.
|
// These are the container configs used to customize container /etc/hosts file.
|
||||||
type hostsPathConfig struct {
|
type hostsPathConfig struct {
|
||||||
// Note(cpuguy83): The linter is drunk and says none of these fields are used while they are
|
// Note(cpuguy83): The linter is drunk and says none of these fields are used while they are
|
||||||
hostName string //nolint:structcheck
|
hostName string
|
||||||
domainName string //nolint:structcheck
|
domainName string
|
||||||
hostsPath string //nolint:structcheck
|
hostsPath string
|
||||||
originHostsPath string //nolint:structcheck
|
originHostsPath string
|
||||||
extraHosts []extraHost //nolint:structcheck
|
extraHosts []extraHost
|
||||||
parentUpdates []parentUpdate //nolint:structcheck
|
parentUpdates []parentUpdate
|
||||||
}
|
}
|
||||||
|
|
||||||
type parentUpdate struct {
|
type parentUpdate struct {
|
||||||
|
@ -115,12 +115,12 @@ type extraHost struct {
|
||||||
// These are the container configs used to customize container /etc/resolv.conf file.
|
// These are the container configs used to customize container /etc/resolv.conf file.
|
||||||
type resolvConfPathConfig struct {
|
type resolvConfPathConfig struct {
|
||||||
// Note(cpuguy83): The linter is drunk and says none of these fields are used while they are
|
// Note(cpuguy83): The linter is drunk and says none of these fields are used while they are
|
||||||
resolvConfPath string //nolint:structcheck
|
resolvConfPath string
|
||||||
originResolvConfPath string //nolint:structcheck
|
originResolvConfPath string
|
||||||
resolvConfHashFile string //nolint:structcheck
|
resolvConfHashFile string
|
||||||
dnsList []string //nolint:structcheck
|
dnsList []string
|
||||||
dnsSearchList []string //nolint:structcheck
|
dnsSearchList []string
|
||||||
dnsOptionsList []string //nolint:structcheck
|
dnsOptionsList []string
|
||||||
}
|
}
|
||||||
|
|
||||||
type containerConfig struct {
|
type containerConfig struct {
|
||||||
|
|
|
@ -16,7 +16,7 @@ import (
|
||||||
|
|
||||||
// Same as DM_DEVICE_* enum values from libdevmapper.h
|
// Same as DM_DEVICE_* enum values from libdevmapper.h
|
||||||
//
|
//
|
||||||
//nolint:deadcode,unused,varcheck
|
//nolint:unused
|
||||||
const (
|
const (
|
||||||
deviceCreate TaskType = iota
|
deviceCreate TaskType = iota
|
||||||
deviceReload
|
deviceReload
|
||||||
|
|
|
@ -22,7 +22,7 @@ const extName = "VolumeDriver"
|
||||||
// This interface is only defined to generate the proxy objects.
|
// This interface is only defined to generate the proxy objects.
|
||||||
// It's not intended to be public or reused.
|
// It's not intended to be public or reused.
|
||||||
//
|
//
|
||||||
//nolint:deadcode,unused,varcheck
|
//nolint:unused
|
||||||
type volumeDriver interface {
|
type volumeDriver interface {
|
||||||
// Create a volume with the given name
|
// Create a volume with the given name
|
||||||
Create(name string, opts map[string]string) (err error)
|
Create(name string, opts map[string]string) (err error)
|
||||||
|
|
Loading…
Reference in a new issue