Skip to content

Commit 62c1f0e

Browse files
committed
Add deadcode linter
Signed-off-by: Daniel Nephin <[email protected]>
1 parent 372670b commit 62c1f0e

File tree

21 files changed

+19
-122
lines changed

21 files changed

+19
-122
lines changed

api/server/httputils/errors.go

-8
Original file line numberDiff line numberDiff line change
@@ -13,14 +13,6 @@ import (
1313
"google.golang.org/grpc/codes"
1414
)
1515

16-
// httpStatusError is an interface
17-
// that errors with custom status codes
18-
// implement to tell the api layer
19-
// which response status to set.
20-
type httpStatusError interface {
21-
HTTPErrorStatusCode() int
22-
}
23-
2416
type causer interface {
2517
Cause() error
2618
}

api/types/filters/parse.go

-8
Original file line numberDiff line numberDiff line change
@@ -276,14 +276,6 @@ func (filters Args) Validate(accepted map[string]bool) error {
276276
return nil
277277
}
278278

279-
type invalidFilterError string
280-
281-
func (e invalidFilterError) Error() string {
282-
return "Invalid filter: '" + string(e) + "'"
283-
}
284-
285-
func (invalidFilterError) InvalidParameter() {}
286-
287279
// WalkValues iterates over the list of filtered values for a field.
288280
// It stops the iteration if it finds an error and it returns that error.
289281
func (filters Args) WalkValues(field string, op func(value string) error) error {

client/client_mock_test.go

+8
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,14 @@ import (
99
"github.com/docker/docker/api/types"
1010
)
1111

12+
// transportFunc allows us to inject a mock transport for testing. We define it
13+
// here so we can detect the tlsconfig and return nil for only this type.
14+
type transportFunc func(*http.Request) (*http.Response, error)
15+
16+
func (tf transportFunc) RoundTrip(req *http.Request) (*http.Response, error) {
17+
return tf(req)
18+
}
19+
1220
func newMockClient(doer func(*http.Request) (*http.Response, error)) *http.Client {
1321
return &http.Client{
1422
Transport: transportFunc(doer),

client/transport.go

-8
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,6 @@ import (
55
"net/http"
66
)
77

8-
// transportFunc allows us to inject a mock transport for testing. We define it
9-
// here so we can detect the tlsconfig and return nil for only this type.
10-
type transportFunc func(*http.Request) (*http.Response, error)
11-
12-
func (tf transportFunc) RoundTrip(req *http.Request) (*http.Response, error) {
13-
return tf(req)
14-
}
15-
168
// resolveTLSConfig attempts to resolve the TLS configuration from the
179
// RoundTripper.
1810
func resolveTLSConfig(transport http.RoundTripper) *tls.Config {

cmd/dockerd/daemon_solaris.go

-13
Original file line numberDiff line numberDiff line change
@@ -5,27 +5,14 @@ package main
55
import (
66
"fmt"
77
"net"
8-
"os"
98
"path/filepath"
109

1110
"github.com/docker/docker/libcontainerd"
12-
"github.com/docker/docker/pkg/system"
1311
"golang.org/x/sys/unix"
1412
)
1513

1614
const defaultDaemonConfigFile = ""
1715

18-
// currentUserIsOwner checks whether the current user is the owner of the given
19-
// file.
20-
func currentUserIsOwner(f string) bool {
21-
if fileInfo, err := system.Stat(f); err == nil && fileInfo != nil {
22-
if int(fileInfo.UID()) == os.Getuid() {
23-
return true
24-
}
25-
}
26-
return false
27-
}
28-
2916
// setDefaultUmask sets the umask to 0022 to avoid problems
3017
// caused by custom umask
3118
func setDefaultUmask() error {

cmd/dockerd/daemon_windows.go

-6
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,6 @@ import (
1414

1515
var defaultDaemonConfigFile = ""
1616

17-
// currentUserIsOwner checks whether the current user is the owner of the given
18-
// file.
19-
func currentUserIsOwner(f string) bool {
20-
return false
21-
}
22-
2317
// setDefaultUmask doesn't do anything on windows
2418
func setDefaultUmask() error {
2519
return nil

daemon/daemon_solaris.go

+4-5
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ import (
2222
"github.com/docker/libnetwork/netlabel"
2323
"github.com/docker/libnetwork/netutils"
2424
lntypes "github.com/docker/libnetwork/types"
25-
"github.com/opencontainers/runtime-spec/specs-go"
25+
specs "github.com/opencontainers/runtime-spec/specs-go"
2626
"github.com/opencontainers/selinux/go-selinux/label"
2727
"github.com/pkg/errors"
2828
"github.com/sirupsen/logrus"
@@ -32,10 +32,9 @@ import (
3232
import "C"
3333

3434
const (
35-
defaultVirtualSwitch = "Virtual Switch"
36-
platformSupported = true
37-
solarisMinCPUShares = 1
38-
solarisMaxCPUShares = 65535
35+
platformSupported = true
36+
solarisMinCPUShares = 1
37+
solarisMaxCPUShares = 65535
3938
)
4039

4140
func getMemoryResources(config containertypes.Resources) specs.CappedMemory {

daemon/daemon_windows.go

-20
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ import (
55
"os"
66
"path/filepath"
77
"strings"
8-
"syscall"
98

109
"github.com/Microsoft/hcsshim"
1110
"github.com/docker/docker/api/types"
@@ -38,9 +37,6 @@ const (
3837
windowsMaxCPUShares = 10000
3938
windowsMinCPUPercent = 1
4039
windowsMaxCPUPercent = 100
41-
windowsMinCPUCount = 1
42-
43-
errInvalidState = syscall.Errno(0x139F)
4440
)
4541

4642
// Windows has no concept of an execution state directory. So use config.Root here.
@@ -60,22 +56,6 @@ func parseSecurityOpt(container *container.Container, config *containertypes.Hos
6056
return nil
6157
}
6258

63-
func getBlkioReadIOpsDevices(config *containertypes.HostConfig) ([]blkiodev.ThrottleDevice, error) {
64-
return nil, nil
65-
}
66-
67-
func getBlkioWriteIOpsDevices(config *containertypes.HostConfig) ([]blkiodev.ThrottleDevice, error) {
68-
return nil, nil
69-
}
70-
71-
func getBlkioReadBpsDevices(config *containertypes.HostConfig) ([]blkiodev.ThrottleDevice, error) {
72-
return nil, nil
73-
}
74-
75-
func getBlkioWriteBpsDevices(config *containertypes.HostConfig) ([]blkiodev.ThrottleDevice, error) {
76-
return nil, nil
77-
}
78-
7959
func (daemon *Daemon) getLayerInit() func(string) error {
8060
return nil
8161
}

daemon/graphdriver/plugin.go

-10
Original file line numberDiff line numberDiff line change
@@ -2,22 +2,12 @@ package graphdriver
22

33
import (
44
"fmt"
5-
"io"
65
"path/filepath"
76

87
"github.com/docker/docker/pkg/plugingetter"
98
"github.com/docker/docker/plugin/v2"
109
)
1110

12-
type pluginClient interface {
13-
// Call calls the specified method with the specified arguments for the plugin.
14-
Call(string, interface{}, interface{}) error
15-
// Stream calls the specified method with the specified arguments for the plugin and returns the response IO stream
16-
Stream(string, interface{}) (io.ReadCloser, error)
17-
// SendFile calls the specified method, and passes through the IO stream
18-
SendFile(string, io.Reader, interface{}) error
19-
}
20-
2111
func lookupPlugin(name string, pg plugingetter.PluginGetter, config Options) (Driver, error) {
2212
if !config.ExperimentalEnabled {
2313
return nil, fmt.Errorf("graphdriver plugins are only supported with experimental mode")

daemon/health.go

+1-2
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,7 @@ const (
4545
const (
4646
// Exit status codes that can be returned by the probe command.
4747

48-
exitStatusHealthy = 0 // Container is healthy
49-
exitStatusUnhealthy = 1 // Container is unhealthy
48+
exitStatusHealthy = 0 // Container is healthy
5049
)
5150

5251
// probe implementations know how to run a particular type of probe.

daemon/metrics.go

+1-2
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import (
66

77
"github.com/docker/docker/pkg/mount"
88
"github.com/docker/docker/pkg/plugingetter"
9-
"github.com/docker/go-metrics"
9+
metrics "github.com/docker/go-metrics"
1010
"github.com/pkg/errors"
1111
"github.com/prometheus/client_golang/prometheus"
1212
"github.com/sirupsen/logrus"
@@ -16,7 +16,6 @@ const metricsPluginType = "MetricsCollector"
1616

1717
var (
1818
containerActions metrics.LabeledTimer
19-
containerStates metrics.LabeledGauge
2019
imageActions metrics.LabeledTimer
2120
networkActions metrics.LabeledTimer
2221
engineInfo metrics.LabeledGauge

hack/dockerfile/install-binaries.sh

+1-6
Original file line numberDiff line numberDiff line change
@@ -60,12 +60,7 @@ install_gometalinter() {
6060
cd "$GOPATH/src/github.com/alecthomas/gometalinter"
6161
git checkout -q "$GOMETALINTER_COMMIT"
6262
go build -o /usr/local/bin/gometalinter github.com/alecthomas/gometalinter
63-
(
64-
export GOBIN=/usr/local/bin
65-
export GOPATH="$PWD/_linters/"
66-
go install github.com/golang/lint/golint
67-
go install golang.org/x/tools/cmd/goimports
68-
)
63+
GOBIN=/usr/local/bin gometalinter --install
6964
}
7065

7166
for prog in "$@"

hack/validate/gometalinter.json

+1
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
],
1111

1212
"Enable": [
13+
"deadcode",
1314
"gofmt",
1415
"goimports",
1516
"golint",

pkg/devicemapper/devmapper.go

+1
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ import (
1414
)
1515

1616
// Same as DM_DEVICE_* enum values from libdevmapper.h
17+
// nolint: deadcode
1718
const (
1819
deviceCreate TaskType = iota
1920
deviceReload

pkg/plugins/pluginrpc-gen/fixtures/foo.go

-6
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,11 @@
11
package foo
22

33
import (
4-
"fmt"
5-
64
aliasedio "io"
75

86
"github.com/docker/docker/pkg/plugins/pluginrpc-gen/fixtures/otherfixture"
97
)
108

11-
var (
12-
errFakeImport = fmt.Errorf("just to import fmt for imports tests")
13-
)
14-
159
type wobble struct {
1610
Some string
1711
Val string

plugin/backend_linux.go

+1-17
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ import (
3232
"github.com/docker/docker/pkg/system"
3333
"github.com/docker/docker/plugin/v2"
3434
refstore "github.com/docker/docker/reference"
35-
"github.com/opencontainers/go-digest"
35+
digest "github.com/opencontainers/go-digest"
3636
"github.com/pkg/errors"
3737
"github.com/sirupsen/logrus"
3838
"golang.org/x/net/context"
@@ -652,22 +652,6 @@ func (pm *Manager) Remove(name string, config *types.PluginRmConfig) error {
652652
return nil
653653
}
654654

655-
func getMounts(root string) ([]string, error) {
656-
infos, err := mount.GetMounts()
657-
if err != nil {
658-
return nil, errors.Wrap(err, "failed to read mount table")
659-
}
660-
661-
var mounts []string
662-
for _, m := range infos {
663-
if strings.HasPrefix(m.Mountpoint, root) {
664-
mounts = append(mounts, m.Mountpoint)
665-
}
666-
}
667-
668-
return mounts, nil
669-
}
670-
671655
// Set sets plugin args
672656
func (pm *Manager) Set(name string, args []string) error {
673657
p, err := pm.config.Store.GetV2Plugin(name)

volume/drivers/extpoint.go

+1
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ func NewVolumeDriver(name string, baseHostPath string, c client) volume.Driver {
3232
// volumeDriver defines the available functions that volume plugins must implement.
3333
// This interface is only defined to generate the proxy objects.
3434
// It's not intended to be public or reused.
35+
// nolint: deadcode
3536
type volumeDriver interface {
3637
// Create a volume with the given name
3738
Create(name string, opts map[string]string) (err error)
File renamed without changes.
File renamed without changes.

volume/volume_unix.go

-4
Original file line numberDiff line numberDiff line change
@@ -119,10 +119,6 @@ func validateNotRoot(p string) error {
119119
return nil
120120
}
121121

122-
func validateCopyMode(mode bool) error {
123-
return nil
124-
}
125-
126122
func convertSlash(p string) string {
127123
return p
128124
}

volume/volume_windows.go

-7
Original file line numberDiff line numberDiff line change
@@ -183,13 +183,6 @@ func validateNotRoot(p string) error {
183183
return nil
184184
}
185185

186-
func validateCopyMode(mode bool) error {
187-
if mode {
188-
return fmt.Errorf("Windows does not support copying image path content")
189-
}
190-
return nil
191-
}
192-
193186
func convertSlash(p string) string {
194187
return filepath.FromSlash(p)
195188
}

0 commit comments

Comments
 (0)