Skip to content

Commit a2915a3

Browse files
authored
Use golangci-lint 2.x (#579)
Signed-off-by: Tamal Saha <tamal@appscode.com>
1 parent ebf2819 commit a2915a3

File tree

121 files changed

+3246
-1231
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

121 files changed

+3246
-1231
lines changed

.golangci.yml

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
version: "2"
2+
linters:
3+
default: standard
4+
enable:
5+
- unparam
6+
7+
formatters:
8+
enable:
9+
- gofmt
10+
- goimports
11+
settings:
12+
gofmt:
13+
rewrite-rules:
14+
- pattern: 'interface{}'
15+
replacement: 'any'
16+
17+
issues:
18+
max-same-issues: 100
19+
20+
exclude-files:
21+
- generated.*\\.go
22+
23+
exclude-dirs:
24+
- client
25+
- vendor
26+
27+
run:
28+
timeout: 10m

Makefile

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -391,8 +391,6 @@ unit-tests: $(BUILD_DIRS)
391391
./hack/test.sh $(SRC_PKGS) \
392392
"
393393

394-
ADDTL_LINTERS := gofmt,goimports,unparam
395-
396394
.PHONY: lint
397395
lint: $(BUILD_DIRS)
398396
@echo "running linter"
@@ -410,7 +408,7 @@ lint: $(BUILD_DIRS)
410408
--env GO111MODULE=on \
411409
--env GOFLAGS="-mod=vendor" \
412410
$(BUILD_IMAGE) \
413-
golangci-lint run --enable $(ADDTL_LINTERS) --max-same-issues=100 --timeout=60m --exclude-files="generated.*\.go$\" --exclude-dirs-use-default --exclude-dirs=client,vendor
411+
golangci-lint run
414412

415413
$(BUILD_DIRS):
416414
@mkdir -p $@

apis/core/fuzzer/fuzzer.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,8 @@ import (
2424
)
2525

2626
// Funcs returns the fuzzer functions for this api group.
27-
var Funcs = func(codecs runtimeserializer.CodecFactory) []interface{} {
28-
return []interface{}{
27+
var Funcs = func(codecs runtimeserializer.CodecFactory) []any {
28+
return []any{
2929
// v1alpha1
3030
func(s *v1alpha1.PodView, c fuzz.Continue) {
3131
c.FuzzNoCustom(s) // fuzz self without calling this function again

apis/identity/fuzzer/fuzzer.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,8 @@ import (
2424
)
2525

2626
// Funcs returns the fuzzer functions for this api group.
27-
var Funcs = func(codecs runtimeserializer.CodecFactory) []interface{} {
28-
return []interface{}{
27+
var Funcs = func(codecs runtimeserializer.CodecFactory) []any {
28+
return []any{
2929
// v1alpha1
3030
func(s *v1alpha1.ClusterIdentity, c fuzz.Continue) {
3131
c.FuzzNoCustom(s) // fuzz self without calling this function again

apis/management/fuzzer/fuzzer.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,8 @@ import (
2424
)
2525

2626
// Funcs returns the fuzzer functions for this api group.
27-
var Funcs = func(codecs runtimeserializer.CodecFactory) []interface{} {
28-
return []interface{}{
27+
var Funcs = func(codecs runtimeserializer.CodecFactory) []any {
28+
return []any{
2929
func(s *v1alpha1.ProjectQuota, c fuzz.Continue) {
3030
c.FuzzNoCustom(s) // fuzz self without calling this function again
3131
},

apis/meta/fuzzer/fuzzer.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,8 @@ import (
2525
)
2626

2727
// Funcs returns the fuzzer functions for this api group.
28-
var Funcs = func(codecs runtimeserializer.CodecFactory) []interface{} {
29-
return []interface{}{
28+
var Funcs = func(codecs runtimeserializer.CodecFactory) []any {
29+
return []any{
3030
func(s *v1alpha1.ResourceDescriptor, c fuzz.Continue) {
3131
c.FuzzNoCustom(s) // fuzz self without calling this function again
3232
},

apis/meta/v1alpha1/schema.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -194,7 +194,7 @@ func FormatMetadata(data []byte) ([]byte, error) {
194194
return yaml.Marshal(root)
195195
}
196196

197-
func find(node yaml.MapSlice, key string) interface{} {
197+
func find(node yaml.MapSlice, key string) any {
198198
for i := range node {
199199
if node[i].Key.(string) == key {
200200
return node[i].Value

apis/meta/v1alpha1/table_types.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,9 +52,9 @@ type TableCell struct {
5252
// cells will be as wide as the column definitions array and may contain strings, numbers (float64 or
5353
// int64), booleans, simple maps, lists, or null. See the type field of the column definition for a
5454
// more detailed description.
55-
Data interface{} `json:"data"`
55+
Data any `json:"data"`
5656
// +optional
57-
Sort interface{} `json:"sort,omitempty"`
57+
Sort any `json:"sort,omitempty"`
5858
// +optional
5959
Link string `json:"link,omitempty"`
6060
// +optional

apis/node/fuzzer/fuzzer.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,8 @@ import (
2424
)
2525

2626
// Funcs returns the fuzzer functions for this api group.
27-
var Funcs = func(codecs runtimeserializer.CodecFactory) []interface{} {
28-
return []interface{}{
27+
var Funcs = func(codecs runtimeserializer.CodecFactory) []any {
28+
return []any{
2929
func(s *v1alpha1.NodeTopology, c fuzz.Continue) {
3030
c.FuzzNoCustom(s) // fuzz self without calling this function again
3131
},

apis/shared/helpers.go

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -37,14 +37,15 @@ const (
3737
)
3838

3939
var pool = sync.Pool{
40-
New: func() interface{} {
40+
New: func() any {
4141
return new(bytes.Buffer)
4242
},
4343
}
4444

45-
func (r ResourceLocator) GraphQuery(oid kmapi.OID) (string, map[string]interface{}, error) {
46-
if r.Query.Type == GraphQLQuery {
47-
vars := map[string]interface{}{
45+
func (r ResourceLocator) GraphQuery(oid kmapi.OID) (string, map[string]any, error) {
46+
switch r.Query.Type {
47+
case GraphQLQuery:
48+
vars := map[string]any{
4849
GraphQueryVarSource: string(oid),
4950
GraphQueryVarTargetGroup: r.Ref.Group,
5051
GraphQueryVarTargetKind: r.Ref.Kind,
@@ -61,7 +62,7 @@ func (r ResourceLocator) GraphQuery(oid kmapi.OID) (string, map[string]interface
6162
}
6263
}
6364
}`, r.Query.ByLabel), vars, nil
64-
} else if r.Query.Type == RESTQuery {
65+
case RESTQuery:
6566
if r.Query.Raw == "" || !strings.Contains(r.Query.Raw, "{{") {
6667
return r.Query.Raw, nil, nil
6768
}

0 commit comments

Comments
 (0)