Skip to content

Commit ab2d494

Browse files
arun717Arun Maurya
andauthored
CM-824: Update golangci-lint to version 2 in operator repo (#356)
* pushing changes and resolving merge conflicts in go.mod manually * Adding Makefile and .golangci.yaml * Adding all remaining files with changes. * Push after make bundle locally. * Handling PR review comments. * Resolving dependencies and downgrading pkg versions. * changing prefix github.com/org/project * from go.mod removing replace on the otelgrpc --------- Co-authored-by: Arun Maurya <amaurya@amaurya-thinkpadp1gen7.bengluru.csb>
1 parent e93acb1 commit ab2d494

3,083 files changed

Lines changed: 286983 additions & 84064 deletions

File tree

Some content is hidden

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

.golangci.yaml

Lines changed: 173 additions & 79 deletions
Original file line numberDiff line numberDiff line change
@@ -1,90 +1,184 @@
1-
# This file contains all available configuration options
2-
# with their default values.
1+
version: "2"
32

4-
# options for analysis running
53
run:
6-
# default concurrency is a available CPU number
7-
concurrency: 4
8-
9-
# timeout for analysis, e.g. 30s, 5m, default is 1m
10-
timeout: 5m
11-
12-
# exit code when at least one issue was found, default is 1
13-
issues-exit-code: 1
14-
15-
# include test files or not, default is true
16-
tests: true
17-
# list of build tags, all linters use it. Default is empty list.
18-
build-tags:
19-
- e2e
20-
21-
# which dirs to skip: issues from them won't be reported;
22-
# can use regexp here: generated.*, regexp is applied on full path;
23-
# default value is empty list, but default dirs are skipped independently
24-
# from this option's value (see skip-dirs-use-default).
25-
# "/" will be replaced by current OS file path separator to properly work
26-
# on Windows.
27-
skip-dirs:
28-
- vendor
29-
30-
# default is true. Enables skipping of directories:
31-
# vendor$, third_party$, testdata$, examples$, Godeps$, builtin$
32-
skip-dirs-use-default: true
33-
34-
# by default isn't set. If set we pass it to "go list -mod={option}". From "go help modules":
35-
# If invoked with -mod=readonly, the go command is disallowed from the implicit
36-
# automatic updating of go.mod described above. Instead, it fails when any changes
37-
# to go.mod are needed. This setting is most useful to check that go.mod does
38-
# not need updates, such as in a continuous integration and testing system.
39-
# If invoked with -mod=vendor, the go command assumes that the vendor
40-
# directory holds the correct copies of dependencies and ignores
41-
# the dependency descriptions in go.mod.
42-
modules-download-mode: vendor
43-
44-
# Allow multiple parallel golangci-lint instances running.
45-
# If false (default) - golangci-lint acquires file lock on start.
46-
allow-parallel-runners: false
47-
48-
49-
# output configuration options
50-
output:
51-
# colored-line-number|line-number|json|tab|checkstyle|code-climate|junit-xml|github-actions
52-
# default is "colored-line-number"
53-
format: tab
54-
55-
# print lines of code with issue, default is true
56-
print-issued-lines: true
57-
58-
# print linter name in the end of issue text, default is true
59-
print-linter-name: true
60-
61-
# make issues output unique by line, default is true
62-
uniq-by-line: true
63-
64-
# add a prefix to the output file references; default is no prefix
65-
path-prefix: ""
66-
67-
# sorts results by: filepath, line and column
68-
sort-results: false
4+
timeout: 10m
5+
allow-parallel-runners: true
696

707
linters:
71-
disable-all: true
8+
default: none
729
enable:
10+
- asasalint
11+
- asciicheck
12+
- bidichk
13+
- bodyclose
14+
- canonicalheader
15+
- contextcheck
16+
- copyloopvar
17+
- decorder
18+
- depguard
19+
- dupword
7320
- errcheck
74-
- gofmt
75-
- goimports
21+
- errchkjson
22+
- errname
23+
- errorlint
24+
- fatcontext
25+
- forbidigo
26+
- forcetypeassert
27+
- funcorder
28+
- gocheckcompilerdirectives
29+
- goconst
30+
- gocritic
31+
- godot
32+
- goheader
33+
- goprintffuncname
7634
- gosec
77-
- gosimple
35+
- gosmopolitan
7836
- govet
79-
- ineffassign
37+
- grouper
38+
- iface
39+
- importas
40+
- intrange
41+
- makezero
8042
- misspell
43+
- musttag
44+
- nakedret
45+
- nestif
46+
- nilerr
47+
- nosprintfhostport
48+
- prealloc
49+
- predeclared
50+
- reassign
51+
- recvcheck
8152
- staticcheck
82-
- typecheck
53+
- tagalign
54+
- unconvert
55+
- unparam
8356
- unused
84-
fast: false
85-
86-
linters-settings:
87-
goimports:
88-
# put imports beginning with prefix after 3rd-party packages;
89-
# it's a comma-separated list of prefixes
90-
local-prefixes: github.com/openshift/cert-manager-operator
57+
- wastedassign
58+
- whitespace
59+
- wrapcheck
60+
disable:
61+
# Below linters will be enabled once the issues reported by enabled linters are fixed.
62+
- dupl
63+
- cyclop
64+
- gocyclo
65+
- gocognit
66+
- err113
67+
- revive
68+
- maintidx
69+
- mnd
70+
# Below linters will be enabled when the golangci-lint is upgraded to the version supporting these.
71+
#- embeddedstructfieldcheck
72+
#- godoclint
73+
#- iotamixing
74+
#- modernize
75+
76+
exclusions:
77+
# Mode of the generated files analysis.
78+
#
79+
# - `strict`: sources are excluded by strictly following the Go generated file convention.
80+
# Source files that have lines matching only the following regular expression will be excluded: `^// Code generated .* DO NOT EDIT\.$`
81+
# This line must appear before the first non-comment, non-blank text in the file.
82+
# https://go.dev/s/generatedcode
83+
# - `lax`: sources are excluded if they contain lines like `autogenerated file`, `code generated`, `do not edit`, etc.
84+
# - `disable`: disable the generated files exclusion.
85+
#
86+
# Default: strict
87+
generated: lax
88+
# Log a warning if an exclusion rule is unused.
89+
# Default: false
90+
warn-unused: true
91+
# Predefined exclusion rules.
92+
# Default: []
93+
presets:
94+
- comments
95+
- std-error-handling
96+
- common-false-positives
97+
- legacy
98+
# Excluding configuration per-path, per-linter, per-text and per-source.
99+
rules:
100+
# Exclude some linters from running on tests files.
101+
- path: _test\.go
102+
linters:
103+
- gocyclo
104+
- errcheck
105+
- dupl
106+
- gosec
107+
- wrapcheck
108+
- mnd
109+
# Run some linter only for test files by excluding its issues for everything else.
110+
- path-except: _test\.go
111+
linters:
112+
- forbidigo
113+
- path: pkg/operators
114+
linters:
115+
- all
116+
formatters:
117+
settings:
118+
gci:
119+
# Section configuration to compare against.
120+
# Section names are case-insensitive and may contain parameters in ().
121+
# The default order of sections is `standard > default > custom > blank > dot > alias > localmodule`.
122+
# If `custom-order` is `true`, it follows the order of `sections` option.
123+
# Default: ["standard", "default"]
124+
sections:
125+
- standard # Standard section: captures all standard packages.
126+
- default # Default section: contains all imports that could not be matched to another section type.
127+
- prefix(github.com/openshift/cert-manager-operator) # Custom section: groups all imports with the specified Prefix.
128+
- blank # Blank section: contains all blank imports. This section is not present unless explicitly enabled.
129+
- dot # Dot section: contains all dot imports. This section is not present unless explicitly enabled.
130+
- alias # Alias section: contains all alias imports. This section is not present unless explicitly enabled.
131+
- localmodule # Local module section: contains all local packages. This section is not present unless explicitly enabled.
132+
# Checks that no inline comments are present.
133+
# Default: false
134+
no-inline-comments: true
135+
# Checks that no prefix comments (comment lines above an import) are present.
136+
# Default: false
137+
no-prefix-comments: true
138+
# Enable custom order of sections.
139+
# If `true`, make the section order the same as the order of `sections`.
140+
# Default: false
141+
custom-order: true
142+
# Drops lexical ordering for custom sections.
143+
# Default: false
144+
no-lex-order: true
145+
gofmt:
146+
# Simplify code: gofmt with `-s` option.
147+
# Default: true
148+
simplify: false
149+
# Apply the rewrite rules to the source before reformatting.
150+
# https://pkg.go.dev/cmd/gofmt
151+
# Default: []
152+
rewrite-rules:
153+
- pattern: 'interface{}'
154+
replacement: 'any'
155+
- pattern: 'a[b:len(a)]'
156+
replacement: 'a[b:]'
157+
gofumpt:
158+
# Module path which contains the source code being formatted.
159+
# Default: ""
160+
module-path: github.com/openshift/cert-manager-operator
161+
# Choose whether to use the extra rules.
162+
# Default: false
163+
extra-rules: true
164+
goimports:
165+
# A list of prefixes, which, if set, checks import paths
166+
# with the given prefixes are grouped after 3rd-party packages.
167+
# Default: []
168+
local-prefixes:
169+
- github.com/openshift/cert-manager-operator
170+
golines:
171+
# Target maximum line length.
172+
# Default: 100
173+
max-len: 200
174+
# Length of a tabulation.
175+
# Default: 4
176+
tab-len: 8
177+
# Shorten single-line comments.
178+
# Default: false
179+
shorten-comments: true
180+
# Default: true
181+
reformat-tags: false
182+
# Split chained methods on the dots as opposed to the arguments.
183+
# Default: true
184+
chain-split-dots: false

Makefile

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ else
6363
GOBIN=$(shell go env GOBIN)
6464
endif
6565

66-
GOLANGCI_LINT ?= go run github.com/golangci/golangci-lint/cmd/golangci-lint
66+
GOLANGCI_LINT ?= go run github.com/golangci/golangci-lint/v2/cmd/golangci-lint
6767

6868
CONTROLLER_GEN := go run sigs.k8s.io/controller-tools/cmd/controller-gen
6969

@@ -306,8 +306,12 @@ test-e2e-debug-cluster:
306306
@echo "---- /Debugging the current state ----"
307307

308308
.PHONY: lint
309-
lint:
310-
$(GOLANGCI_LINT) run --config .golangci.yaml
309+
lint:
310+
$(GOLANGCI_LINT) run --verbose --config .golangci.yaml
311+
312+
.PHONY: lint-fix
313+
lint-fix:
314+
$(GOLANGCI_LINT) run --config .golangci.yaml --fix
311315

312316
$(GOLANGCI_LINT_BIN):
313317
mkdir -p $(BIN_DIR)

api/operator/v1alpha1/certmanager_types.go

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import (
77
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
88
)
99

10-
// CertManagerSpec defines the desired state of CertManager
10+
// CertManagerSpec defines the desired state of CertManager.
1111
type CertManagerSpec struct {
1212
apiv1.OperatorSpec `json:",inline"`
1313

@@ -39,7 +39,7 @@ type CertManagerSpec struct {
3939
//
4040
// For OverrideArgs,
4141
// --config string Path to a file containing a WebhookConfiguration object used to configure the webhook
42-
// --dynamic-serving-ca-secret-name string name of the secret used to store the CA that signs serving certificates certificates
42+
// --dynamic-serving-ca-secret-name string name of the secret used to store the CA that signs serving certificates
4343
// --dynamic-serving-ca-secret-namespace string namespace of the secret used to store the CA that signs serving certificates
4444
// --dynamic-serving-dns-names strings DNS names that should be present on certificates generated by the dynamic serving CA
4545
// --v Level number for the log level verbosity
@@ -172,7 +172,7 @@ type CertManagerScheduling struct {
172172
Tolerations []corev1.Toleration `json:"tolerations,omitempty" protobuf:"bytes,22,opt,name=tolerations"`
173173
}
174174

175-
// CertManagerStatus defines the observed state of CertManager
175+
// CertManagerStatus defines the observed state of CertManager.
176176
type CertManagerStatus struct {
177177
apiv1.OperatorStatus `json:",inline"`
178178
}
@@ -218,7 +218,7 @@ type UnsupportedConfigOverridesForCertManagerCAInjector struct {
218218
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
219219
//+kubebuilder:object:root=true
220220

221-
// CertManagerList contains a list of CertManager
221+
// CertManagerList contains a list of CertManager.
222222
type CertManagerList struct {
223223
metav1.TypeMeta `json:",inline"`
224224
metav1.ListMeta `json:"metadata"`
@@ -230,13 +230,13 @@ type CertManagerList struct {
230230
type ComponentName string
231231

232232
const (
233-
// CAInjector represents the cert-manager CA injector component
233+
// CAInjector represents the cert-manager CA injector component.
234234
CAInjector ComponentName = "CAInjector"
235235

236-
// CoreController represents the cert-manager core controller component
236+
// CoreController represents the cert-manager core controller component.
237237
CoreController ComponentName = "CoreController"
238238

239-
// Webhook represents the cert-manager webhook component
239+
// Webhook represents the cert-manager webhook component.
240240
Webhook ComponentName = "Webhook"
241241
)
242242

api/operator/v1alpha1/groupversion_info.go

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

2727
var (
28-
// SchemeGroupVersion is group version used to register these objects
28+
// SchemeGroupVersion is group version used to register these objects.
2929
SchemeGroupVersion = schema.GroupVersion{Group: "operator.openshift.io", Version: "v1alpha1"}
3030

31-
// SchemeBuilder is used to add go types to the GroupVersionKind scheme
31+
// SchemeBuilder is used to add go types to the GroupVersionKind scheme.
3232
SchemeBuilder = &scheme.Builder{GroupVersion: SchemeGroupVersion}
3333

3434
// AddToScheme adds the types in this group-version to the given scheme.
3535
AddToScheme = SchemeBuilder.AddToScheme
3636
)
3737

3838
// Manually added to conform to k8s code-generator lister-gen.
39-
// Resource takes an unqualified resource and returns a Group qualified GroupResource
39+
// Resource takes an unqualified resource and returns a Group qualified GroupResource.
4040
func Resource(resource string) schema.GroupResource {
4141
return SchemeGroupVersion.WithResource(resource).GroupResource()
4242
}

api/operator/v1alpha1/istiocsr_types.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,8 @@ type IstioCSRList struct {
2121
// metadata is the standard list's metadata.
2222
// More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#metadata
2323
metav1.ListMeta `json:"metadata"`
24-
Items []IstioCSR `json:"items"`
24+
25+
Items []IstioCSR `json:"items"`
2526
}
2627

2728
// +genclient

0 commit comments

Comments
 (0)