Skip to content

Commit 25716f8

Browse files
authored
Upgrade lint (#267)
* Update linter Update to same version used by other OF repos. Update config to match other OF repos. Signed-off-by: Andy Goldstein <[email protected]> * Run goimports Signed-off-by: Andy Goldstein <[email protected]> * Fix lint Signed-off-by: Andy Goldstein <[email protected]> --------- Signed-off-by: Andy Goldstein <[email protected]>
1 parent f78cdcc commit 25716f8

Some content is hidden

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

46 files changed

+561
-321
lines changed

.bingo/Variables.mk

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,11 +23,11 @@ $(BINGO): $(BINGO_DIR)/bingo.mod
2323
@echo "(re)installing $(GOBIN)/bingo-v0.9.0"
2424
@cd $(BINGO_DIR) && GOWORK=off $(GO) build -mod=mod -modfile=bingo.mod -o=$(GOBIN)/bingo-v0.9.0 "github.com/bwplotka/bingo"
2525

26-
GOLANGCI_LINT := $(GOBIN)/golangci-lint-v1.51.2
26+
GOLANGCI_LINT := $(GOBIN)/golangci-lint-v1.55.2
2727
$(GOLANGCI_LINT): $(BINGO_DIR)/golangci-lint.mod
2828
@# Install binary/ries using Go 1.14+ build command. This is using bwplotka/bingo-controlled, separate go module with pinned dependencies.
29-
@echo "(re)installing $(GOBIN)/golangci-lint-v1.51.2"
30-
@cd $(BINGO_DIR) && GOWORK=off $(GO) build -mod=mod -modfile=golangci-lint.mod -o=$(GOBIN)/golangci-lint-v1.51.2 "github.com/golangci/golangci-lint/cmd/golangci-lint"
29+
@echo "(re)installing $(GOBIN)/golangci-lint-v1.55.2"
30+
@cd $(BINGO_DIR) && GOWORK=off $(GO) build -mod=mod -modfile=golangci-lint.mod -o=$(GOBIN)/golangci-lint-v1.55.2 "github.com/golangci/golangci-lint/cmd/golangci-lint"
3131

3232
GORELEASER := $(GOBIN)/goreleaser-v1.20.0
3333
$(GORELEASER): $(BINGO_DIR)/goreleaser.mod

.bingo/golangci-lint.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@ module _ // Auto generated by https://github.com/bwplotka/bingo. DO NOT EDIT
22

33
go 1.20
44

5-
require github.com/golangci/golangci-lint v1.51.2 // cmd/golangci-lint
5+
require github.com/golangci/golangci-lint v1.55.2 // cmd/golangci-lint

.bingo/golangci-lint.sum

Lines changed: 156 additions & 0 deletions
Large diffs are not rendered by default.

.bingo/variables.env

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ fi
1010

1111
BINGO="${GOBIN}/bingo-v0.9.0"
1212

13-
GOLANGCI_LINT="${GOBIN}/golangci-lint-v1.51.2"
13+
GOLANGCI_LINT="${GOBIN}/golangci-lint-v1.55.2"
1414

1515
GORELEASER="${GOBIN}/goreleaser-v1.20.0"
1616

.golangci.yml

Lines changed: 75 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,78 @@
11
run:
2-
timeout: 5m
2+
# Default timeout is 1m, up to give more room
3+
timeout: 4m
4+
35
linters:
4-
disable-all: true
56
enable:
6-
- govet
7-
- errcheck
8-
- staticcheck
9-
- unused
10-
- gosimple
11-
- structcheck
12-
- varcheck
13-
- ineffassign
14-
- deadcode
15-
- typecheck
16-
- gofmt
17-
- goconst
7+
- asciicheck
8+
- bodyclose
9+
- errorlint
10+
- ginkgolinter
11+
- gofmt
12+
- goimports
13+
- gosec
14+
- importas
15+
- misspell
16+
- nestif
17+
- nonamedreturns
18+
- prealloc
19+
- revive
20+
- stylecheck
21+
- tparallel
22+
- unconvert
23+
- unparam
24+
- unused
25+
- whitespace
26+
27+
linters-settings:
28+
errorlint:
29+
errorf: false
30+
31+
importas:
32+
alias:
33+
- pkg: k8s.io/apimachinery/pkg/apis/meta/v1
34+
alias: metav1
35+
- pkg: k8s.io/apimachinery/pkg/api/errors
36+
alias: apierrors
37+
- pkg: k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1
38+
alias: apiextensionsv1
39+
- pkg: k8s.io/apimachinery/pkg/util/runtime
40+
alias: utilruntime
41+
- pkg: "^k8s\\.io/api/([^/]+)/(v[^/]+)$"
42+
alias: $1$2
43+
- pkg: sigs.k8s.io/controller-runtime
44+
alias: ctrl
45+
46+
goimports:
47+
local-prefixes: github.com/operator-framework/helm-operator-plugins
48+
49+
revive:
50+
ignore-generated-header: false
51+
severity: warning
52+
confidence: 0.8
53+
rules:
54+
- name: blank-imports
55+
- name: context-as-argument
56+
- name: context-keys-type
57+
- name: error-return
58+
- name: error-strings
59+
- name: error-naming
60+
- name: exported
61+
- name: increment-decrement
62+
- name: var-naming
63+
- name: var-declaration
64+
- name: package-comments
65+
- name: range
66+
- name: receiver-naming
67+
- name: time-naming
68+
- name: unexported-return
69+
- name: indent-error-flow
70+
- name: errorf
71+
- name: empty-block
72+
- name: superfluous-else
73+
- name: unused-parameter
74+
- name: unreachable-code
75+
- name: redefines-builtin-id
76+
77+
output:
78+
format: tab

hack/generate/samples/generate_testdata.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,5 +52,4 @@ func main() {
5252

5353
log.Infof("creating Hybrid Memcached Sample")
5454
hybrid.GenerateMemcachedSamples(binaryPath, samplesPath)
55-
5655
}

hack/generate/samples/internal/pkg/context.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,9 @@ type SampleContext struct {
2222
}
2323

2424
// NewSampleContext returns a SampleContext containing a new kubebuilder TestContext.
25-
func NewSampleContext(binary string, path string, env ...string) (s SampleContext, err error) {
25+
func NewSampleContext(binary string, path string, env ...string) (SampleContext, error) {
26+
var s SampleContext
27+
var err error
2628
s.TestContext, err = testutils.NewPartialTestContext(binary, path, env...)
2729
return s, err
2830
}

internal/cmd/helm-operator/run/cmd.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -200,7 +200,6 @@ func run(cmd *cobra.Command, f *flags.Flags) {
200200
log.Error(err, "Manager exited non-zero.")
201201
os.Exit(1)
202202
}
203-
204203
}
205204

206205
// exitIfUnsupported prints an error containing unsupported field names and exits

internal/flags/flag.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,6 @@ func (f *Flags) AddTo(flagSet *pflag.FlagSet) {
117117
" holding the leader lock (required if running locally with leader"+
118118
" election enabled).",
119119
)
120-
121120
}
122121

123122
// ToManagerOptions uses the flag set in f to configure options.

internal/sdk/controllerutil/controllerutil.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,8 @@ var (
4444
func WaitForDeletion(ctx context.Context, cl client.Reader, o client.Object) error {
4545
key := client.ObjectKeyFromObject(o)
4646

47-
return wait.PollUntilContextCancel(ctx, time.Millisecond*10, true, func(ctx context.Context) (done bool, err error) {
48-
err = cl.Get(ctx, key, o)
47+
return wait.PollUntilContextCancel(ctx, time.Millisecond*10, true, func(ctx context.Context) (bool, error) {
48+
err := cl.Get(ctx, key, o)
4949
if apierrors.IsNotFound(err) {
5050
return true, nil
5151
}

0 commit comments

Comments
 (0)