Skip to content

Commit ad7b2c9

Browse files
authored
Merge pull request #151 from crossplane-contrib/golang-ci-v2
update golangci-lint version to 2.6.1
2 parents 3c96ca9 + 913edc4 commit ad7b2c9

File tree

5 files changed

+125
-178
lines changed

5 files changed

+125
-178
lines changed

.golangci.yml

Lines changed: 121 additions & 173 deletions
Original file line numberDiff line numberDiff line change
@@ -1,186 +1,134 @@
1+
version: "2"
12
run:
2-
timeout: 10m
33
concurrency: 1
4-
54
output:
6-
# colored-line-number|line-number|json|tab|checkstyle|code-climate, default is "colored-line-number"
75
formats:
8-
- format: colored-line-number
9-
print-linter-name: true
10-
11-
linters-settings:
12-
errcheck:
13-
# report about not checking of errors in type assetions: `a := b.(MyStruct)`;
14-
# default is false: such cases aren't reported by default.
15-
check-type-assertions: false
16-
17-
# report about assignment of errors to blank identifier: `num, _ := strconv.Atoi(numStr)`;
18-
# default is false: such cases aren't reported by default.
19-
check-blank: false
20-
21-
exclude-functions:
22-
- io/ioutil.ReadFile
23-
- io/ioutil.ReadDir
24-
- io/ioutil.ReadAll
25-
26-
govet:
27-
# report about shadowed variables
28-
check-shadowing: false
29-
30-
revive:
31-
# confidence for issues, default is 0.8
32-
confidence: 0.8
33-
34-
gofmt:
35-
# simplify code: gofmt with `-s` option, true by default
36-
simplify: true
37-
38-
goimports:
39-
# put imports beginning with prefix after 3rd-party packages;
40-
# it's a comma-separated list of prefixes
41-
local-prefixes: github.com/crossplane-contrib/provider-openstack
42-
43-
gocyclo:
44-
# minimal code complexity to report, 30 by default (but we recommend 10-20)
45-
min-complexity: 10
46-
47-
dupl:
48-
# tokens count to trigger issue, 150 by default
49-
threshold: 100
50-
51-
goconst:
52-
# minimal length of string constant, 3 by default
53-
min-len: 3
54-
# minimal occurrences count to trigger, 3 by default
55-
min-occurrences: 5
56-
57-
lll:
58-
# tab width in spaces. Default to 1.
59-
tab-width: 1
60-
61-
unparam:
62-
# Inspect exported functions, default is false. Set to true if no external program/library imports your code.
63-
# XXX: if you enable this setting, unparam will report a lot of false-positives in text editors:
64-
# if it's called for subdir of a project it can't find external interfaces. All text editor integrations
65-
# with golangci-lint call it on a directory with the changed file.
66-
check-exported: false
67-
68-
nakedret:
69-
# make an issue if func has more lines of code than this setting and it has naked returns; default is 30
70-
max-func-lines: 30
71-
72-
prealloc:
73-
# XXX: we don't recommend using this linter before doing performance profiling.
74-
# For most programs usage of prealloc will be a premature optimization.
75-
76-
# Report preallocation suggestions only on simple loops that have no returns/breaks/continues/gotos in them.
77-
# True by default.
78-
simple: true
79-
range-loops: true # Report preallocation suggestions on range loops, true by default
80-
for-loops: false # Report preallocation suggestions on for loops, false by default
81-
82-
gocritic:
83-
# Enable multiple checks by tags, run `GL_DEBUG=gocritic golangci-lint` run to see all tags and checks.
84-
# Empty list by default. See https://github.com/go-critic/go-critic#usage -> section "Tags".
85-
enabled-tags:
86-
- performance
87-
88-
settings: # settings passed to gocritic
89-
captLocal: # must be valid enabled check name
90-
paramsOnly: true
91-
rangeValCopy:
92-
sizeThreshold: 32
93-
6+
text:
7+
path: stdout
8+
print-linter-name: true
949
linters:
9510
enable:
96-
- govet
97-
- gocyclo
98-
- gocritic
11+
- asasalint
12+
- asciicheck
13+
- bidichk
14+
- bodyclose
15+
- contextcheck
16+
- durationcheck
17+
- errchkjson
18+
- errorlint
19+
- exhaustive
20+
- gocheckcompilerdirectives
21+
- gochecksumtype
9922
- goconst
100-
- goimports
101-
- gofmt # We enable this as well as goimports for its simplify mode.
102-
- gosimple
23+
- gocritic
24+
- gocyclo
25+
- gosec
26+
- gosmopolitan
27+
- loggercheck
28+
- makezero
29+
- misspell
30+
- musttag
31+
- nakedret
32+
- nilerr
33+
- nilnesserr
34+
- noctx
10335
- prealloc
36+
- protogetter
37+
- reassign
38+
- recvcheck
10439
- revive
105-
- staticcheck
40+
- rowserrcheck
41+
- spancheck
42+
- sqlclosecheck
43+
- testifylint
10644
- unconvert
107-
- unused
108-
- misspell
109-
- nakedret
110-
111-
presets:
112-
- bugs
113-
- unused
114-
fast: false
115-
45+
- unparam
46+
- zerologlint
47+
settings:
48+
dupl:
49+
threshold: 100
50+
errcheck:
51+
check-type-assertions: false
52+
check-blank: false
53+
exclude-functions:
54+
- io/ioutil.ReadFile
55+
- io/ioutil.ReadDir
56+
- io/ioutil.ReadAll
57+
goconst:
58+
min-len: 3
59+
min-occurrences: 5
60+
gocritic:
61+
enabled-tags:
62+
- performance
63+
settings:
64+
captLocal:
65+
paramsOnly: true
66+
rangeValCopy:
67+
sizeThreshold: 32
68+
gocyclo:
69+
min-complexity: 10
70+
lll:
71+
tab-width: 1
72+
nakedret:
73+
max-func-lines: 30
74+
prealloc:
75+
simple: true
76+
range-loops: true
77+
for-loops: false
78+
revive:
79+
confidence: 0.8
80+
unparam:
81+
check-exported: false
82+
exclusions:
83+
generated: lax
84+
rules:
85+
- linters:
86+
- dupl
87+
- errcheck
88+
- gocyclo
89+
- gosec
90+
- scopelint
91+
- unparam
92+
path: _test(ing)?\.go
93+
- linters:
94+
- gocritic
95+
path: _test\.go
96+
text: (unnamedResult|exitAfterDefer)
97+
- linters:
98+
- gocritic
99+
text: '(hugeParam|rangeValCopy):'
100+
- linters:
101+
- staticcheck
102+
text: 'SA3000:'
103+
- linters:
104+
- gosec
105+
text: 'G101:'
106+
- linters:
107+
- gosec
108+
text: 'G104:'
109+
paths:
110+
- zz_.*go$
111+
- third_party$
112+
- builtin$
113+
- examples$
116114
issues:
117-
exclude-files:
118-
- "zz_.*go$"
119-
# Excluding configuration per-path and per-linter
120-
exclude-rules:
121-
# Exclude some linters from running on tests files.
122-
- path: _test(ing)?\.go
123-
linters:
124-
- gocyclo
125-
- errcheck
126-
- dupl
127-
- gosec
128-
- scopelint
129-
- unparam
130-
131-
# Ease some gocritic warnings on test files.
132-
- path: _test\.go
133-
text: "(unnamedResult|exitAfterDefer)"
134-
linters:
135-
- gocritic
136-
137-
# These are performance optimisations rather than style issues per se.
138-
# They warn when function arguments or range values copy a lot of memory
139-
# rather than using a pointer.
140-
- text: "(hugeParam|rangeValCopy):"
141-
linters:
142-
- gocritic
143-
144-
# This "TestMain should call os.Exit to set exit code" warning is not clever
145-
# enough to notice that we call a helper method that calls os.Exit.
146-
- text: "SA3000:"
147-
linters:
148-
- staticcheck
149-
150-
- text: "k8s.io/api/core/v1"
151-
linters:
152-
- goimports
153-
154-
# This is a "potential hardcoded credentials" warning. It's triggered by
155-
# any variable with 'secret' in the same, and thus hits a lot of false
156-
# positives in Kubernetes land where a Secret is an object type.
157-
- text: "G101:"
158-
linters:
159-
- gosec
160-
- gas
161-
162-
# This is an 'errors unhandled' warning that duplicates errcheck.
163-
- text: "G104:"
164-
linters:
165-
- gosec
166-
- gas
167-
168-
# Independently from option `exclude` we use default exclude patterns,
169-
# it can be disabled by this option. To list all
170-
# excluded by default patterns execute `golangci-lint run --help`.
171-
# Default value for this option is true.
172-
exclude-use-default: false
173-
174-
# Show only new issues: if there are unstaged changes or untracked files,
175-
# only those changes are analyzed, else only changes in HEAD~ are analyzed.
176-
# It's a super-useful option for integration of golangci-lint into existing
177-
# large codebase. It's not practical to fix all existing issues at the moment
178-
# of integration: much better don't allow issues in new code.
179-
# Default is false.
180-
new: false
181-
182-
# Maximum issues count per one linter. Set to 0 to disable. Default is 50.
183115
max-issues-per-linter: 0
184-
185-
# Maximum count of issues with the same text. Set to 0 to disable. Default is 3.
186116
max-same-issues: 0
117+
new: false
118+
formatters:
119+
enable:
120+
- gofmt
121+
- goimports
122+
settings:
123+
gofmt:
124+
simplify: true
125+
goimports:
126+
local-prefixes:
127+
- github.com/crossplane-contrib/provider-openstack
128+
exclusions:
129+
generated: lax
130+
paths:
131+
- zz_.*go$
132+
- third_party$
133+
- builtin$
134+
- examples$

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1414
- Update to golang `v1.24.4`
1515
- Update to upjet `v1.9.0`
1616
- Update golang dependencies
17+
- Update golangci-lint to `2.6.1`
1718

1819
## [0.7.2] - 2025-07-02
1920

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ GO_TEST_PARALLEL := $(shell echo $$(( $(NPROCS) / 2 )))
3838
GO_REQUIRED_VERSION ?= 1.24
3939
# GOLANGCILINT_VERSION is inherited from build submodule by default.
4040
# Uncomment below if you need to override the version.
41-
GOLANGCILINT_VERSION ?= 1.64.8
41+
GOLANGCILINT_VERSION ?= 2.6.1
4242

4343
GO_STATIC_PACKAGES = $(GO_PROJECT)/cmd/provider $(GO_PROJECT)/cmd/generator
4444
GO_LDFLAGS += -X $(GO_PROJECT)/internal/version.Version=$(VERSION)

apis/generate.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
//go:build generate
2-
// +build generate
32

43
// NOTE: See the below link for details on what is happening here.
54
// https://github.com/golang/go/wiki/Modules#how-can-i-track-tool-dependencies-for-a-module

config/provider.go

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ import (
77
// Note(turkenh): we are importing this to embed provider schema document
88
_ "embed"
99

10-
"github.com/crossplane/upjet/pkg/config"
1110
ujconfig "github.com/crossplane/upjet/pkg/config"
1211
"github.com/crossplane/upjet/pkg/registry/reference"
1312
"github.com/crossplane/upjet/pkg/schema/traverser"
@@ -169,8 +168,8 @@ func bumpVersionsWithEmbeddedLists(pc *ujconfig.Provider) {
169168
// with the converted API (with embedded objects in place of
170169
// singleton lists), so we need the appropriate Terraform
171170
// converter in this case.
172-
r.TerraformConversions = []config.TerraformConversion{
173-
config.NewTFSingletonConversion(),
171+
r.TerraformConversions = []ujconfig.TerraformConversion{
172+
ujconfig.NewTFSingletonConversion(),
174173
}
175174
}
176175
pc.Resources[name] = r

0 commit comments

Comments
 (0)