Skip to content

Commit 7a420f1

Browse files
authored
Fix linter issues (#2527)
* Fix lint errors to fix master Travis is currently failing on master due to these linting errors: https://travis-ci.org/GoogleContainerTools/skaffold/jobs/562352608 * Use less memory on Travis CI + Also print more logs + Also fails in case of an OOM or deadline exceeded Signed-off-by: David Gageot <[email protected]>
1 parent 185d1af commit 7a420f1

File tree

9 files changed

+34
-25
lines changed

9 files changed

+34
-25
lines changed

hack/linter.sh

+32-15
Original file line numberDiff line numberDiff line change
@@ -23,19 +23,36 @@ if ! [ -x "$(command -v golangci-lint)" ]; then
2323
${DIR}/install_golint.sh -b $GOPATH/bin v1.17.1
2424
fi
2525

26-
golangci-lint run \
27-
--deadline=2m \
26+
VERBOSE=""
27+
if [[ "${TRAVIS}" == "true" ]]; then
28+
# Use less memory on Travis
29+
# See https://github.com/golangci/golangci-lint#memory-usage-of-golangci-lint
30+
export GOGC=10
31+
VERBOSE="-v --print-resources-usage"
32+
fi
33+
34+
golangci-lint run ${VERBOSE} \
35+
--deadline=4m \
2836
--no-config \
29-
-E bodyclose \
30-
-E goconst \
31-
-E goimports \
32-
-E gocritic \
33-
-E golint \
34-
-E interfacer \
35-
-E maligned \
36-
-E misspell \
37-
-E stylecheck \
38-
-E unconvert \
39-
-E unparam \
40-
-D errcheck \
41-
--skip-dirs vendor
37+
--disable-all \
38+
-E bodyclose \
39+
-E deadcode \
40+
-E goconst \
41+
-E gocritic \
42+
-E goimports \
43+
-E golint \
44+
-E gosimple \
45+
-E govet \
46+
-E ineffassign \
47+
-E interfacer \
48+
-E maligned \
49+
-E misspell \
50+
-E staticcheck \
51+
-E structcheck \
52+
-E stylecheck \
53+
-E typecheck \
54+
-E unconvert \
55+
-E unparam \
56+
-E unused \
57+
-E varcheck \
58+
--skip-dirs vendor | awk '/out of memory/ || /Deadline exceeded/ {failed = 1}; {print}; END {exit failed}'

pkg/skaffold/build/tag/date_time_test.go

-2
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,6 @@ func TestDateTime_GenerateFullyQualifiedImageName(t *testing.T) {
3333
buildTime time.Time
3434
timezone string
3535
imageName string
36-
digest string
37-
image string
3836
want string
3937
}{
4038
{

pkg/skaffold/deploy/kubectl_test.go

-1
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,6 @@ func TestKubectlDeploy(t *testing.T) {
6363
shouldErr bool
6464
forceDeploy bool
6565
expectedDependencies []string
66-
warnings []string
6766
}{
6867
{
6968
description: "no manifest",

pkg/skaffold/docker/client_test.go

-2
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ import (
2121

2222
"github.com/GoogleContainerTools/skaffold/pkg/skaffold/util"
2323
"github.com/GoogleContainerTools/skaffold/testutil"
24-
"github.com/docker/docker/client"
2524
)
2625

2726
func TestNewEnvClient(t *testing.T) {
@@ -60,7 +59,6 @@ func TestNewMinikubeImageAPIClient(t *testing.T) {
6059
tests := []struct {
6160
description string
6261
env string
63-
expected client.CommonAPIClient
6462
expectedEnv []string
6563
shouldErr bool
6664
}{

pkg/skaffold/docker/docker_init_test.go

-1
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,6 @@ func TestCreateArtifact(t *testing.T) {
9292
dockerfile Docker
9393
manifestImage string
9494
expectedArtifact latest.Artifact
95-
expectedImage string
9695
}{
9796
{
9897
description: "default filename",

pkg/skaffold/kubernetes/log_test.go

-1
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,6 @@ func TestSinceSeconds(t *testing.T) {
5454
func TestSelect(t *testing.T) {
5555
tests := []struct {
5656
description string
57-
images []string
5857
podSpec v1.PodSpec
5958
expectedMatch bool
6059
}{

pkg/skaffold/runner/intent.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ type intents struct {
3030
lock *gosync.Mutex
3131
}
3232

33-
func NewIntents(autoBuild, autoSync, autoDeploy bool) *intents {
33+
func newIntents(autoBuild, autoSync, autoDeploy bool) *intents {
3434
i := &intents{
3535
lock: &gosync.Mutex{},
3636
resetBuild: func() {},

pkg/skaffold/runner/runner.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,7 @@ func NewForConfig(opts *config.SkaffoldOptions, cfg *latest.SkaffoldConfig) (*Sk
167167
imageList: kubernetes.NewImageList(),
168168
cache: artifactCache,
169169
runCtx: runCtx,
170-
intents: NewIntents(opts.AutoBuild, opts.AutoSync, opts.AutoDeploy),
170+
intents: newIntents(opts.AutoBuild, opts.AutoSync, opts.AutoDeploy),
171171
}
172172

173173
if err := r.setupTriggerCallbacks(intentChan); err != nil {

pkg/skaffold/schema/versions_test.go

-1
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,6 @@ func TestParseConfig(t *testing.T) {
109109
description string
110110
config string
111111
expected util.VersionedConfig
112-
badReader bool
113112
shouldErr bool
114113
}{
115114
{

0 commit comments

Comments
 (0)