Skip to content

Commit ca80799

Browse files
authored
Modernize golangci-lint config (#1082)
- Enable bodyclose and prealloc linters - Move exclude-files/exclude-dirs to linters.exclusions.paths (golangci-lint v2 location) and fix over-escaped regex generated.*\\.go -> generated.*\.go - Switch formatter from gofmt to gofumpt and drop the interface{} -> any rewrite rule (gofumpt is a stricter superset) - Apply resulting gofumpt formatting Signed-off-by: Tamal Saha <tamal@appscode.com>
1 parent ffa9ab3 commit ca80799

3 files changed

Lines changed: 14 additions & 16 deletions

File tree

.golangci.yml

Lines changed: 8 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2,27 +2,22 @@ version: "2"
22
linters:
33
default: standard
44
enable:
5+
- bodyclose
6+
- prealloc
57
- unparam
8+
exclusions:
9+
paths:
10+
- generated.*\.go
11+
- client
12+
- vendor
613

714
formatters:
815
enable:
9-
- gofmt
16+
- gofumpt
1017
- goimports
11-
settings:
12-
gofmt:
13-
rewrite-rules:
14-
- pattern: 'interface{}'
15-
replacement: 'any'
1618

1719
issues:
1820
max-same-issues: 100
1921

20-
exclude-files:
21-
- generated.*\\.go
22-
23-
exclude-dirs:
24-
- client
25-
- vendor
26-
2722
run:
2823
timeout: 10m

apis/wizards/v1alpha1/register.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,8 @@ func Resource(resource string) schema.GroupResource {
5353

5454
// Adds the list of known types to api.Scheme.
5555
func addKnownTypes(scheme *runtime.Scheme) error {
56-
scheme.AddKnownTypes(SchemeGroupVersion,
56+
scheme.AddKnownTypes(
57+
SchemeGroupVersion,
5758
&KubedbcomDruidEditorOptions{},
5859
&KubedbcomDruidEditorOptionsList{},
5960
&KubedbcomElasticsearchEditorOptions{},
@@ -94,7 +95,8 @@ func addKnownTypes(scheme *runtime.Scheme) error {
9495
&StoragekubestashcomBackupstorageEditorOptionsList{},
9596
)
9697

97-
scheme.AddKnownTypes(SchemeGroupVersion,
98+
scheme.AddKnownTypes(
99+
SchemeGroupVersion,
98100
&metav1.Status{},
99101
)
100102
metav1.AddToGroupVersion(scheme, SchemeGroupVersion)

apis/wizards/v1alpha1/types_test.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,8 @@ import (
2626
)
2727

2828
func TestDefaultValues(t *testing.T) {
29-
checker := schemachecker.New(os.DirFS("../../.."),
29+
checker := schemachecker.New(
30+
os.DirFS("../../.."),
3031
schemachecker.TestCase{Obj: v1alpha1.KubedbcomElasticsearchEditorOptionsSpec{}},
3132
schemachecker.TestCase{Obj: v1alpha1.KubedbcomMariadbEditorOptionsSpec{}},
3233
schemachecker.TestCase{Obj: v1alpha1.KubedbcomMemcachedEditorOptionsSpec{}},

0 commit comments

Comments
 (0)