Skip to content

Commit b39ae15

Browse files
ci: use golangci-lint v2
and use autofix Signed-off-by: Pascal Bourdier <pascal.bourdier@gmail.com>
1 parent 6483dd5 commit b39ae15

File tree

30 files changed

+116
-112
lines changed

30 files changed

+116
-112
lines changed

.golangci.yml

Lines changed: 40 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,38 +1,46 @@
1-
run:
2-
timeout: 5m
1+
version: "2"
32
linters:
43
enable:
5-
- nakedret
6-
- misspell
7-
- ineffassign
4+
- dupl
85
- ginkgolinter
96
- goconst
10-
- goimports
11-
- errcheck
12-
- dupl
13-
- unparam
14-
- revive
15-
- staticcheck
16-
- unused
17-
- gosimple
18-
- unconvert
197
- gocyclo
208
- gosec
21-
issues:
22-
exclude-rules:
23-
# Allow dot imports for ginkgo and gomega
24-
- source: ginkgo|gomega
25-
linters:
26-
- revive
27-
text: "should not use dot imports"
28-
29-
- linters:
30-
- gosec
31-
# these exclusion rules are for current failures in the code base for gosec which are
32-
# excluded for future PRs which include:
33-
# G110: Potential DoS vulnerability via decompression bomb
34-
# G204: Audit use of command execution
35-
# G306: Poor file permissions used when writing to a new file
36-
# G404: Insecure random number source (rand)
37-
# G601: Implicit memory aliasing of items from a range statement
38-
text: "G110|G601|G404|G204|G306"
9+
- misspell
10+
- nakedret
11+
- revive
12+
- unconvert
13+
- unparam
14+
exclusions:
15+
generated: lax
16+
presets:
17+
- comments
18+
- common-false-positives
19+
- legacy
20+
- std-error-handling
21+
rules:
22+
- linters:
23+
- revive
24+
text: should not use dot imports
25+
source: ginkgo|gomega
26+
- linters:
27+
- gosec
28+
text: G110|G601|G404|G204|G306
29+
paths:
30+
- third_party$
31+
- builtin$
32+
- examples$
33+
settings:
34+
revive:
35+
rules:
36+
- name: var-naming
37+
disabled: true
38+
formatters:
39+
enable:
40+
- goimports
41+
exclusions:
42+
generated: lax
43+
paths:
44+
- third_party$
45+
- builtin$
46+
- examples$

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ fix: ## Fixup files in the repo.
6161

6262
.PHONY: setup-lint
6363
setup-lint: ## Setup the lint
64-
$(SCRIPTS_DIR)/fetch golangci-lint 1.64.8
64+
$(SCRIPTS_DIR)/fetch golangci-lint 2.6.2
6565

6666
.PHONY: lint
6767
lint: setup-lint ## Run the lint check

hack/generate/cli-doc/gen-cli-doc.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ func recreateDocDir(rootCmd *cobra.Command, docPath string) {
8282
filePrepender := func(filename string) string {
8383
name := filepath.Base(filename)
8484
base := strings.TrimSuffix(name, path.Ext(name))
85-
return fmt.Sprintf(fmTemplate, strings.Replace(base, "_", " ", -1))
85+
return fmt.Sprintf(fmTemplate, strings.ReplaceAll(base, "_", " "))
8686
}
8787
linkHandler := func(name string) string {
8888
base := strings.TrimSuffix(name, path.Ext(name))

hack/generate/samples/internal/go/memcached-with-customization/e2e_test_code.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ func (mh *Memcached) implementingE2ETests() {
2323
testUtilsDir := filepath.Join(testDir, "utils")
2424

2525
// Following we will create the directories
26-
// Create the golang files with a string replace inside onlu
26+
// Create the golang files with a string replace inside only
2727
// Then, replace the string replace by the template contents
2828
mh.createDirs(testDir, testE2eDir, testUtilsDir)
2929
mh.createGoFiles(testE2eDir, testUtilsDir)

internal/cmd/operator-sdk/generate/bundle/bundle.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ func (c bundleCmd) validateManifests() (err error) {
134134
isInputDir := c.inputDir != ""
135135
isLegacyDirs := c.deployDir != "" || c.crdsDir != ""
136136
switch {
137-
case !(isPipeReader || isInputDir || isLegacyDirs):
137+
case !isPipeReader && !isInputDir && !isLegacyDirs:
138138
return errors.New("one of stdin, --input-dir, or --deploy-dir (and optionally --crds-dir) must be set")
139139
case isPipeReader && (isInputDir || isLegacyDirs):
140140
return errors.New("none of --input-dir, --deploy-dir, or --crds-dir may be set if reading from stdin")

internal/cmd/operator-sdk/generate/bundle/cmd.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@ func (c *bundleCmd) addFlagsTo(fs *pflag.FlagSet) {
147147
}
148148

149149
func (c bundleCmd) println(a ...interface{}) {
150-
if !(c.quiet || c.stdout) {
150+
if !c.quiet && !c.stdout {
151151
fmt.Println(a...)
152152
}
153153
}

internal/cmd/operator-sdk/generate/internal/relatedimages.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -147,5 +147,5 @@ func (c *relatedImageCollector) collectedRelatedImages() []operatorsv1alpha1.Rel
147147

148148
// formatName transforms RELATED_IMAGE_This_IS_a_cool_image to this-is-a-cool-image
149149
func (c *relatedImageCollector) formatName(name string) string {
150-
return strings.ToLower(strings.Replace(strings.TrimPrefix(name, relatedImagePrefix), "_", "-", -1))
150+
return strings.ToLower(strings.ReplaceAll(strings.TrimPrefix(name, relatedImagePrefix), "_", "-"))
151151
}

internal/cmd/operator-sdk/generate/packagemanifests/cmd.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ func (c *packagemanifestsCmd) addFlagsTo(fs *pflag.FlagSet) {
112112
}
113113

114114
func (c packagemanifestsCmd) println(a ...interface{}) {
115-
if !(c.quiet || c.stdout) {
115+
if !c.quiet && !c.stdout {
116116
fmt.Println(a...)
117117
}
118118
}

internal/cmd/operator-sdk/pkgmantobundle/pkgmantobundle_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ var _ = Describe("Running pkgmanToBundle command", func() {
3333
var (
3434
p pkgManToBundleCmd
3535
pkgManDir string
36-
outputDir string = "bundle-output"
36+
outputDir = "bundle-output"
3737
)
3838

3939
BeforeEach(func() {

internal/cmd/operator-sdk/scorecard/cmd.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -194,9 +194,10 @@ func (c *scorecardCmd) run() (err error) {
194194
}
195195

196196
podSecFlag := true
197-
if c.podSecurity == "restricted" {
197+
switch c.podSecurity {
198+
case "restricted":
198199
podSecFlag = true
199-
} else if c.podSecurity == "legacy" {
200+
case "legacy":
200201
podSecFlag = false
201202
}
202203

0 commit comments

Comments
 (0)