Skip to content

Commit 50a59eb

Browse files
committed
initial commit
Signed-off-by: Philippe Scorsolini <p.scorsolini@gmail.com>
1 parent 476b2cd commit 50a59eb

File tree

2 files changed

+169
-191
lines changed

2 files changed

+169
-191
lines changed

.github/workflows/ci.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@ on:
1414

1515
env:
1616
# Common versions
17-
GO_VERSION: '1.23.6'
18-
GOLANGCI_VERSION: 'v1.62.0'
17+
GO_VERSION: '1.24.9'
18+
GOLANGCI_VERSION: 'v2.8.0'
1919
DOCKER_BUILDX_VERSION: 'v0.23.0'
2020

2121
IMAGE_NAME: ghcr.io/${{ github.repository }}

.golangci.yml

Lines changed: 167 additions & 189 deletions
Original file line numberDiff line numberDiff line change
@@ -1,199 +1,177 @@
1-
run:
2-
timeout: 10m
1+
version: "2"
32

43
output:
5-
# colored-line-number|line-number|json|tab|checkstyle|code-climate, default is "colored-line-number"
64
formats:
7-
- format: colored-line-number
8-
9-
linters-settings:
10-
errcheck:
11-
# report about not checking of errors in type assetions: `a := b.(MyStruct)`;
12-
# default is false: such cases aren't reported by default.
13-
check-type-assertions: false
14-
15-
# report about assignment of errors to blank identifier: `num, _ := strconv.Atoi(numStr)`;
16-
# default is false: such cases aren't reported by default.
17-
check-blank: false
18-
19-
# List of functions to exclude from checking, where each entry is a single function to exclude.
20-
# See https://github.com/kisielk/errcheck#excluding-functions for details.
21-
exclude-functions:
22-
- io/ioutil.ReadFile
23-
24-
govet:
25-
# report about shadowed variables
26-
disable:
27-
- shadow
28-
29-
gofmt:
30-
# simplify code: gofmt with `-s` option, true by default
31-
simplify: true
32-
33-
gci:
34-
custom-order: true
35-
sections:
36-
- standard
37-
- default
38-
- prefix(github.com/crossplane)
39-
- prefix(github.com/crossplane-contrib)
40-
- blank
41-
- dot
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-
94-
nolintlint:
95-
require-explanation: true
96-
require-specific: true
97-
5+
text:
6+
path: stderr
987

998
linters:
100-
enable:
101-
- gosimple
102-
- staticcheck
103-
- unused
104-
- govet
9+
default: all
10+
disable:
11+
# These are linters we'd like to enable, but that will be labor intensive to
12+
# make existing code compliant.
13+
- wrapcheck
14+
- varnamelen
15+
- testpackage
16+
- paralleltest
17+
- nilnil
18+
- funcorder
19+
20+
# These linters add whitespace in an attempt to make code more readable.
21+
- wsl
22+
- wsl_v5
23+
- nlreturn
24+
25+
# Warns about uses of fmt.Sprintf that are less performant than alternatives.
26+
- perfsprint
27+
28+
# Overly strict error handling requirements.
29+
- err113
30+
31+
# These linters duplicate gocognit, but calculate complexity differently.
10532
- gocyclo
106-
- gocritic
107-
- goconst
108-
- gci
109-
- gofmt # We enable this as well as goimports for its simplify mode.
110-
- prealloc
111-
- revive
112-
- unconvert
113-
- misspell
114-
- nakedret
115-
- nolintlint
116-
117-
presets:
118-
- bugs
119-
- unused
120-
fast: false
121-
33+
- cyclop
34+
- nestif
35+
- funlen
36+
- maintidx
37+
38+
# Enforces max line length. It's not idiomatic to enforce a strict limit.
39+
- lll
40+
41+
# Warns about struct instantiations that don't specify every field.
42+
- exhaustruct
43+
44+
# Warns about TODO comments.
45+
- godox
46+
47+
# Warns about duplicated code blocks.
48+
- dupl
49+
50+
# Warns about returning interfaces rather than concrete types.
51+
- ireturn
52+
53+
# Warns about returning named variables.
54+
- nonamedreturns
55+
56+
# Warns about using magic numbers.
57+
- mnd
58+
59+
# Warns about if err := Foo(); err != nil style error checks.
60+
- noinlineerr
61+
62+
# We need replace directives during development for unreleased dependencies.
63+
- gomoddirectives
64+
65+
settings:
66+
depguard:
67+
rules:
68+
no_third_party_test_libraries:
69+
list-mode: lax
70+
files:
71+
- $test
72+
deny:
73+
- pkg: github.com/stretchr/testify
74+
desc: See https://go.dev/wiki/TestComments#assert-libraries
75+
errcheck:
76+
check-type-assertions: false
77+
check-blank: false
78+
goconst:
79+
min-len: 3
80+
min-occurrences: 5
81+
gocritic:
82+
enabled-tags:
83+
- performance
84+
settings:
85+
captLocal:
86+
paramsOnly: true
87+
rangeValCopy:
88+
sizeThreshold: 32
89+
govet:
90+
disable:
91+
- shadow
92+
interfacebloat:
93+
max: 5
94+
nakedret:
95+
max-func-lines: 30
96+
nolintlint:
97+
require-explanation: true
98+
require-specific: true
99+
prealloc:
100+
simple: true
101+
range-loops: true
102+
for-loops: false
103+
unparam:
104+
check-exported: false
105+
unused:
106+
exported-fields-are-used: true
107+
108+
exclusions:
109+
generated: lax
110+
rules:
111+
- linters:
112+
- containedctx
113+
- errcheck
114+
- forcetypeassert
115+
- gochecknoglobals
116+
- gochecknoinits
117+
- gocognit
118+
- gosec
119+
- unparam
120+
path: _test(ing)?\.go
121+
122+
- linters:
123+
- gocritic
124+
path: _test\.go
125+
text: (unnamedResult|exitAfterDefer)
126+
127+
- linters:
128+
- gocritic
129+
text: "(hugeParam|rangeValCopy):"
130+
131+
- linters:
132+
- staticcheck
133+
text: "SA3000:"
134+
135+
- linters:
136+
- gosec
137+
text: "G101:"
138+
139+
- linters:
140+
- gosec
141+
text: "G104:"
142+
143+
- linters:
144+
- gosec
145+
text: "G601:"
146+
147+
paths:
148+
- zz_generated\..+\.go$
149+
- .+\.pb.go$
122150

123151
issues:
124-
# Excluding configuration per-path and per-linter
125-
exclude-rules:
126-
- path: "zz_generated\\..+\\.go$"
127-
linters: ["all"]
128-
129-
# Exclude some linters from running on tests files.
130-
- path: _test(ing)?\.go
131-
linters:
132-
- gocyclo
133-
- errcheck
134-
- dupl
135-
- gosec
136-
- scopelint
137-
- unparam
138-
139-
# Ease some gocritic warnings on test files.
140-
- path: _test\.go
141-
text: "(unnamedResult|exitAfterDefer)"
142-
linters:
143-
- gocritic
144-
145-
# These are performance optimisations rather than style issues per se.
146-
# They warn when function arguments or range values copy a lot of memory
147-
# rather than using a pointer.
148-
- text: "(hugeParam|rangeValCopy):"
149-
linters:
150-
- gocritic
151-
152-
# This "TestMain should call os.Exit to set exit code" warning is not clever
153-
# enough to notice that we call a helper method that calls os.Exit.
154-
- text: "SA3000:"
155-
linters:
156-
- staticcheck
157-
158-
- text: "k8s.io/api/core/v1"
159-
linters:
160-
- goimports
161-
162-
# This is a "potential hardcoded credentials" warning. It's triggered by
163-
# any variable with 'secret' in the same, and thus hits a lot of false
164-
# positives in Kubernetes land where a Secret is an object type.
165-
- text: "G101:"
166-
linters:
167-
- gosec
168-
- gas
169-
170-
# This is an 'errors unhandled' warning that duplicates errcheck.
171-
- text: "G104:"
172-
linters:
173-
- gosec
174-
- gas
175-
176-
# Some k8s dependencies do not have JSON tags on all fields in structs.
177-
- path: k8s.io/
178-
linters:
179-
- musttag
180-
181-
# Independently from option `exclude` we use default exclude patterns,
182-
# it can be disabled by this option. To list all
183-
# excluded by default patterns execute `golangci-lint run --help`.
184-
# Default value for this option is true.
185-
exclude-use-default: false
186-
187-
# Show only new issues: if there are unstaged changes or untracked files,
188-
# only those changes are analyzed, else only changes in HEAD~ are analyzed.
189-
# It's a super-useful option for integration of golangci-lint into existing
190-
# large codebase. It's not practical to fix all existing issues at the moment
191-
# of integration: much better don't allow issues in new code.
192-
# Default is false.
193-
new: false
194-
195-
# Maximum issues count per one linter. Set to 0 to disable. Default is 50.
196152
max-issues-per-linter: 0
153+
max-same-issues: 0
154+
new: false
197155

198-
# Maximum count of issues with the same text. Set to 0 to disable. Default is 3.
199-
max-same-issues: 0
156+
formatters:
157+
enable:
158+
- gci
159+
- gofmt
160+
- gofumpt
161+
- goimports
162+
settings:
163+
gci:
164+
sections:
165+
- standard
166+
- default
167+
- prefix(github.com/crossplane)
168+
- blank
169+
- dot
170+
custom-order: true
171+
gofmt:
172+
simplify: true
173+
exclusions:
174+
generated: lax
175+
paths:
176+
- zz_generated\..+\.go$
177+
- .+\.pb.go$

0 commit comments

Comments
 (0)