Skip to content

Commit f837e41

Browse files
committed
Use new golinter configuration
Signed-off-by: Alexander Dahmen <alexander.dahmen@inovex.de>
1 parent 8f210a9 commit f837e41

File tree

8 files changed

+263
-312
lines changed

8 files changed

+263
-312
lines changed

.golangci.yml

Lines changed: 240 additions & 66 deletions
Original file line numberDiff line numberDiff line change
@@ -1,95 +1,269 @@
1-
# This file contains all available configuration options
2-
# with their default values.
3-
4-
# options for analysis running
5-
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
111
linters-settings:
2+
errcheck:
3+
# report about not checking of errors in type assetions: `a := b.(MyStruct)`;
4+
# default is false: such cases aren't reported by default.
5+
check-type-assertions: true
6+
7+
# report about assignment of errors to blank identifier: `num, _ := strconv.Atoi(numStr)`;
8+
# default is false: such cases aren't reported by default.
9+
check-blank: true
10+
exhaustive:
11+
# Presence of "default" case in switch statements satisfies exhaustiveness,
12+
# even if all enum members are not listed.
13+
default-signifies-exhaustive: true
14+
funlen:
15+
lines: 100
16+
statements: 50
17+
gci:
18+
custom-order: true
19+
sections:
20+
- standard
21+
- default
22+
- prefix(dev.azure.com/schwarzit)
1223
goimports:
13-
# put imports beginning with prefix after 3rd-party packages;
14-
# it's a comma-separated list of prefixes
15-
local-prefixes: github.com/freiheit-com/nmww
24+
local-prefixes: dev.azure.com/schwarzit
25+
gofmt:
26+
# simplify code: gofmt with `-s` option, true by default
27+
simplify: true
28+
gocyclo:
29+
min-complexity: 30
30+
gocognit:
31+
min-complexity: 30
32+
dupl:
33+
threshold: 150
34+
goconst:
35+
min-len: 3
36+
min-occurrences: 2
37+
govet:
38+
enable-all: true
39+
disable:
40+
- fieldalignment
1641
depguard:
1742
rules:
18-
main:
19-
list-mode: lax # Everything is allowed unless it is denied
43+
all:
2044
deny:
21-
- pkg: "github.com/stretchr/testify"
22-
desc: Do not use a testing framework
45+
- pkg: github.com/sirupsen/logrus
46+
desc: logging is done using the internal/log and log/slog package
47+
- pkg: log$
48+
desc: logging is done using the internal/log and log/slog package
49+
- pkg: go.uber.org/zap
50+
desc: logging is done using the internal/log and log/slog package
2351
misspell:
24-
# Correct spellings using locale preferences for US or UK.
25-
# Default is to use a neutral variety of English.
26-
# Setting locale to US will correct the British spelling of 'colour' to 'color'.
2752
locale: US
28-
golint:
29-
min-confidence: 0.8
30-
gosec:
31-
excludes:
32-
# Suppressions: (see https://github.com/securego/gosec#available-rules for details)
33-
- G104 # "Audit errors not checked" -> which we don't need and is a badly implemented version of errcheck
34-
- G102 # "Bind to all interfaces" -> since this is normal in k8s
35-
- G304 # "File path provided as taint input" -> too many false positives
36-
- G307 # "Deferring unsafe method "Close" on type "io.ReadCloser" -> false positive when calling defer resp.Body.Close()
53+
lll:
54+
line-length: 140
55+
tab-width: 1
56+
cyclop:
57+
# the maximal code complexity to report
58+
max-complexity: 20
59+
# the maximal average package complexity. If it's higher than 0.0 (float) the check is enabled (default 0.0)
60+
package-average: 0.0
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
3767
nakedret:
38-
max-func-lines: 0
68+
# make an issue if func has more lines of code than this setting and it has naked returns; default is 30
69+
max-func-lines: 5
70+
prealloc:
71+
# XXX: we don't recommend using this linter before doing performance profiling.
72+
# For most programs usage of prealloc will be a premature optimization.
73+
74+
# Report preallocation suggestions only on simple loops that have no returns/breaks/continues/gotos in them.
75+
# True by default.
76+
simple: true
77+
range-loops: true # Report preallocation suggestions on range loops, true by default
78+
for-loops: true # Report preallocation suggestions on for loops, false by default
79+
gocritic:
80+
enabled-tags:
81+
- diagnostic
82+
- experimental
83+
- opinionated
84+
- performance
85+
- style
86+
disabled-checks:
87+
- dupImport # https://github.com/go-critic/go-critic/issues/845
88+
- octalLiteral
89+
- unnamedResult
90+
# Settings passed to gocritic.
91+
# The settings key is the name of a supported gocritic checker.
92+
# The list of supported checkers can be find in https://go-critic.github.io/overview.
93+
settings:
94+
hugeParam:
95+
# Size in bytes that makes the warning trigger.
96+
# Default: 80
97+
sizeThreshold: 80
98+
dogsled:
99+
# checks assignments with too many blank identifiers; default is 2
100+
max-blank-identifiers: 2
101+
whitespace:
102+
multi-if: false # Enforces newlines (or comments) after every multi-line if statement
103+
multi-func: false # Enforces newlines (or comments) after every multi-line function signature
104+
gomoddirectives:
105+
# List of allowed `replace` directives. Default is empty.
106+
# Add your allowed `replace` targets here, this rule is so you don't accidentally commit replacements you added for testing
107+
replace-allow-list: [github.com/hashicorp/terraform-plugin-sdk/v2]
108+
mnd:
109+
# don't include the "operation" and "assign"
110+
checks:
111+
- argument
112+
- case
113+
- condition
114+
- return
115+
- operation
116+
- assign
117+
nolintlint:
118+
allow-unused: false # report any unused nolint directives
119+
require-explanation: true # require an explanation for nolint directives
120+
require-specific: true # require nolint directives to be specific about which linter is being skipped
121+
nlreturn:
122+
# Size of the block (including return statement that is still "OK")
123+
# so no return split required.
124+
block-size: 5
125+
stylecheck:
126+
initialisms: ["ACL", "API", "ASCII", "CPU", "CSS", "DNS", "EOF", "GUID", "HTML", "HTTP", "HTTPS", "ID", "IP", "JSON", "QPS", "RAM", "RPC", "SLA", "SMTP", "SQL", "SSH", "TCP", "TLS", "TTL", "UDP", "UI", "GID", "UID", "UUID", "URI", "URL", "UTF8", "VM", "XML", "XMPP", "XSRF", "XSS", "SIP", "RTP", "AMQP", "DB", "TS"]
39127
revive:
40-
ignore-generated-header: true
41-
severity: error
42-
# https://github.com/mgechev/revive
43128
rules:
129+
- name: context-keys-type
130+
disabled: false
131+
- name: time-naming
132+
disabled: false
133+
- name: var-declaration
134+
disabled: false
135+
- name: unexported-return
136+
disabled: false
44137
- name: errorf
138+
disabled: false
139+
- name: blank-imports
140+
disabled: false
45141
- name: context-as-argument
142+
disabled: false
143+
- name: dot-imports
144+
disabled: false
46145
- name: error-return
146+
disabled: false
147+
- name: error-strings
148+
disabled: false
149+
- name: error-naming
150+
disabled: false
151+
- name: exported
152+
disabled: false
47153
- name: increment-decrement
154+
disabled: false
155+
- name: var-naming
156+
disabled: false
157+
- name: package-comments
158+
disabled: false
159+
- name: range
160+
disabled: false
161+
- name: receiver-naming
162+
disabled: false
48163
- name: indent-error-flow
49-
- name: superfluous-else
50-
- name: unused-parameter
51-
- name: unreachable-code
52-
- name: atomic
53-
- name: empty-lines
54-
- name: early-return
55-
gocritic:
56-
enabled-tags:
57-
- performance
58-
- style
59-
- experimental
60-
disabled-checks:
61-
- wrapperFunc
62-
- typeDefFirst
63-
- ifElseChain
64-
- dupImport # https://github.com/go-critic/go-critic/issues/845
164+
disabled: false
165+
65166
linters:
167+
# please, do not use `enable-all`: it's deprecated and will be removed soon.
168+
# inverted configuration with `enable-all` and `disable` is not scalable during updates of golangci-lint
169+
disable-all: true
66170
enable:
67-
# https://golangci-lint.run/usage/linters/
68-
# default linters
69-
- gosimple
70-
- govet
71-
- ineffassign
72-
- staticcheck
73-
- typecheck
74-
- unused
75-
# additional linters
76-
- errorlint
171+
- depguard
172+
- dogsled
173+
- dupl
174+
- copyloopvar
175+
- exhaustive
176+
- funlen
77177
- gochecknoinits
178+
- goconst
78179
- gocritic
180+
- gocyclo
181+
- godot
79182
- gofmt
80183
- goimports
184+
- mnd
185+
- goprintffuncname
81186
- gosec
187+
- gosimple
188+
- govet
189+
- ineffassign
190+
- lll
191+
- gosimple
192+
- staticcheck
193+
- unused
82194
- misspell
83195
- nakedret
196+
- nolintlint
84197
- revive
85-
- depguard
198+
- staticcheck
199+
- stylecheck
200+
- typecheck
201+
- unconvert
202+
- unused
203+
- whitespace
204+
- gochecknoglobals
205+
- err113
206+
- prealloc
207+
- asciicheck
208+
- nestif
86209
- bodyclose
210+
- cyclop
211+
- durationcheck
212+
- errcheck
213+
- errorlint
214+
- forbidigo
215+
- forcetypeassert
216+
- gci
217+
- gocognit
218+
- gofumpt
219+
- gomoddirectives
220+
- gomodguard
221+
- importas
222+
- makezero
223+
- nilerr
224+
- nlreturn
225+
- noctx
226+
- predeclared
227+
- promlinter
228+
- rowserrcheck
87229
- sqlclosecheck
230+
- tparallel
231+
- unparam
88232
- wastedassign
89-
- forcetypeassert
90-
- errcheck
91-
disable:
92-
- noctx # false positive: finds errors with http.NewRequest that dont make sense
93-
- unparam # false positives
233+
- wsl
234+
235+
# don't enable:
236+
# - tagliatelle # have a different naming schema
237+
# - golint # deprecated
238+
# - scopelint # deprecated
239+
# - interfacer # deprecated
240+
# - testpackage # this is not best practice in go
241+
# - godox # we want to use keywords like TODO or FIX in the code
242+
243+
94244
issues:
95-
exclude-use-default: false
245+
# Excluding configuration per-path, per-linter, per-text and per-source
246+
exclude-rules:
247+
- path: _test\.go
248+
linters:
249+
- gochecknoglobals
250+
- noctx
251+
- funlen
252+
- err113
253+
- mnd
254+
- forcetypeassert
255+
- dogsled
256+
- goconst
257+
- unparam
258+
- dupl
259+
- text: 'declaration of "err" shadows declaration'
260+
linters:
261+
- govet
262+
max-same-issues: 0
263+
max-issues-per-linter: 0
264+
run:
265+
timeout: 10m
266+
issues-exit-code: 1
267+
tests: true
268+
build-tags:
269+
- integration

examples/dotnet/README.md

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,8 @@
1010
a. Check existing nuget sources via `dotnet nuget list source`
1111
b. If there is no local nuget repository present you can add it to the list via
1212
`dotnet nuget add source <PATH-TO-NUGET-FOLDER>`
13-
7. Move to a example folder like `getNetwork` and add the package via `dotnet add package Pulumi.Stackit --prerelease`
14-
8. Adjust the example e.g. modifiy the project id
15-
9. Run the example via `pulumi up`
16-
10. Remove the created resources with `pulumi down`
13+
8. Ensure that the `pulumi-resource-stackit` provider is in your GOPATH (located under pulumi-stackit/bin)
14+
9. Move to a example folder like `getNetwork` and add the package via `dotnet add package Pulumi.Stackit --prerelease`
15+
10. Adjust the example e.g. modifiy the project id
16+
11. Run the example via `pulumi up`
17+
12. Remove the created resources with `pulumi down`

0 commit comments

Comments
 (0)