Skip to content

Commit fa71e62

Browse files
authored
Merge pull request #21870 from afbjorklund/golint-config
Update golangci-lint version and config with linters and formatters
2 parents 8038b50 + 561bf41 commit fa71e62

File tree

10 files changed

+89
-18
lines changed

10 files changed

+89
-18
lines changed

.golangci.max.yaml

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
version: "2"
2+
linters:
3+
enable:
4+
- dogsled
5+
- errcheck
6+
- gocritic
7+
- govet
8+
- gocyclo
9+
- ineffassign
10+
- misspell
11+
- nakedret
12+
- revive
13+
- staticcheck
14+
- unconvert
15+
- unparam
16+
- unused
17+
exclusions:
18+
paths:
19+
- third_party
20+
formatters:
21+
enable:
22+
- gofmt
23+
- goimports
24+
exclusions:
25+
paths:
26+
- third_party

.golangci.min.yaml

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
version: "2"
2+
linters:
3+
enable:
4+
- govet
5+
- gocyclo
6+
disable:
7+
- errcheck
8+
- staticcheck
9+
exclusions:
10+
generated: lax
11+
presets:
12+
- comments
13+
- common-false-positives
14+
- legacy
15+
- std-error-handling
16+
paths:
17+
- third_party
18+
- '(.+)_test\.go'
19+
formatters:
20+
enable:
21+
- gofmt
22+
- goimports
23+
exclusions:
24+
generated: lax
25+
paths:
26+
- third_party

.golangci.yaml

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,19 @@ run:
33
timeout: 7m
44
linters:
55
enable:
6+
- dogsled
7+
- errcheck
68
- gocritic
7-
- revive
9+
- govet
810
- gocyclo
11+
- ineffassign
912
- misspell
1013
- nakedret
14+
- revive
1115
- staticcheck
1216
- unconvert
1317
- unparam
14-
- dogsled
18+
- unused
1519
settings:
1620
staticcheck:
1721
checks:
@@ -23,6 +27,7 @@ linters:
2327
- "-ST1020"
2428
- "-ST1021"
2529
- "-ST1022"
30+
# Omit embedded fields from selector expression
2631
- "-QF1008"
2732

2833
revive:
@@ -165,3 +170,10 @@ linters:
165170
- path: '(.+)\.go$'
166171
text: "Error return value of `.*` is not checked"
167172
linter: errcheck
173+
formatters:
174+
enable:
175+
- gofmt
176+
- goimports
177+
exclusions:
178+
paths:
179+
- third_party

Makefile

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,15 +74,20 @@ MINIKUBE_RELEASES_URL=https://github.com/kubernetes/minikube/releases/download
7474

7575
# latest from https://github.com/golangci/golangci-lint/releases
7676
# update this only by running `make update-golint-version`
77-
GOLINT_VERSION ?= v2.1.5
77+
GOLINT_VERSION ?= v2.1.6
78+
# see https://golangci-lint.run/docs/configuration/file/ for config details
79+
GOLINT_CONFIG ?= .golangci.yaml
80+
# Set this to --verbose to see details about the linters and formatters used
81+
GOLINT_VERBOSE ?=
7882
# Limit number of default jobs, to avoid the CI builds running out of memory
7983
GOLINT_JOBS ?= 4
8084
# see https://github.com/golangci/golangci-lint#memory-usage-of-golangci-lint
8185
GOLINT_GOGC ?= 100
8286
# options for lint (golangci-lint)
8387
GOLINT_OPTIONS = \
88+
--max-issues-per-linter 0 --max-same-issues 0 \
8489
--build-tags "${MINIKUBE_INTEGRATION_BUILD_TAGS}" \
85-
--config .golangci.yaml
90+
--config $(GOLINT_CONFIG) $(GOLINT_VERBOSE)
8691

8792
export GO111MODULE := on
8893

cmd/minikube/cmd/config/view.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ type ViewTemplate struct {
4040
var configViewCmd = &cobra.Command{
4141
Use: "view",
4242
Short: "Display values currently set in the minikube config file",
43-
Long: `Display values currently set in the minikube config file.
43+
Long: `Display values currently set in the minikube config file.
4444
The output format can be customized using the --format flag, which accepts a Go template.
4545
The config file is typically located at "~/.minikube/config/config.json".`,
4646
Run: func(_ *cobra.Command, _ []string) {

cmd/minikube/cmd/start.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -544,7 +544,7 @@ func updateDriver(driverName string) {
544544
}
545545
if errors.Is(err, auxdriver.ErrAuxDriverVersionNotinPath) {
546546
exit.Error(reason.DrvAuxNotHealthy, "Aux driver"+driverName, err)
547-
} //if failed to update but not a fatal error, log it and continue (old version might still work)
547+
} // if failed to update but not a fatal error, log it and continue (old version might still work)
548548
out.WarningT("Unable to update {{.driver}} driver: {{.error}}", out.V{"driver": driverName, "error": err})
549549
}
550550
}

pkg/minikube/assets/addons_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ func mapsEqual(a, b map[string]string) bool {
4545

4646
func TestParseMapString(t *testing.T) {
4747
cases := map[string]map[string]string{
48-
"Aardvark=1,B=2,Cantaloupe=3": {"Aardvark": "1", "B": "2", "Cantaloupe": "3"},
48+
"Aardvark=1,B=2,Cantaloupe=3": {"Aardvark": "1", "B": "2", "Cantaloupe": "3"},
4949
"A=,B=2,C=": {"A": "", "B": "2", "C": ""},
5050
"": {},
5151
"malformed,good=howdy,manyequals==,": {"good": "howdy"},

pkg/minikube/assets/vm_assets.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,13 +20,13 @@ import (
2020
"bytes"
2121
"embed"
2222
"fmt"
23-
"text/template"
2423
"io"
2524
"os"
2625
"path"
2726
"path/filepath"
2827
"strconv"
2928
"strings"
29+
"text/template"
3030
"time"
3131

3232
"github.com/pkg/errors"

pkg/minikube/download/licenses.go

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -67,15 +67,15 @@ func Licenses(dir string) error {
6767
return fmt.Errorf("failed to create temporary file: %v", err)
6868
}
6969
defer func() {
70-
if err := os.Remove(tempFile.Name()); err != nil {
71-
klog.Warningf("Failed to remove temp file %s: %v", tempFile.Name(), err)
72-
}
73-
}()
70+
if err := os.Remove(tempFile.Name()); err != nil {
71+
klog.Warningf("Failed to remove temp file %s: %v", tempFile.Name(), err)
72+
}
73+
}()
7474
defer func() {
75-
if err := tempFile.Close(); err != nil {
76-
klog.Warningf("Failed to close temp file %s: %v", tempFile.Name(), err)
77-
}
78-
}()
75+
if err := tempFile.Close(); err != nil {
76+
klog.Warningf("Failed to close temp file %s: %v", tempFile.Name(), err)
77+
}
78+
}()
7979

8080
if _, err := io.Copy(tempFile, resp.Body); err != nil {
8181
return fmt.Errorf("failed to copy downloaded content from %s: %v", url, err)

pkg/minikube/tunnel/route_windows_test.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -139,11 +139,13 @@ Persistent Routes:
139139
expectedRt := routingTable{
140140
routingTableLine{
141141
route: unsafeParseRoute("127.0.0.1", "10.96.0.0/12"),
142-
line: " 10.96.0.0 255.240.0.0 127.0.0.1 127.0.0.1 281",
142+
line: " 10.96.0.0 255.240.0.0" +
143+
" 127.0.0.1 127.0.0.1 281",
143144
},
144145
routingTableLine{
145146
route: unsafeParseRoute("192.168.1.2", "10.211.55.0/24"),
146-
line: " 10.211.55.0 255.255.255.0 192.168.1.2 10.211.55.3 281",
147+
line: " 10.211.55.0 255.255.255.0" +
148+
" 192.168.1.2 10.211.55.3 281",
147149
},
148150
}
149151
if !reflect.DeepEqual(rt.String(), expectedRt.String()) {

0 commit comments

Comments
 (0)