Skip to content

Commit 5859bf3

Browse files
committed
feat(TFP): Upgrade TFP linter to golangci-lint v2
relates to STACKITTPR-253
1 parent f0f453f commit 5859bf3

File tree

23 files changed

+127
-177
lines changed

23 files changed

+127
-177
lines changed

golang-ci.yaml

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

43
# options for analysis running
54
run:
65
# default concurrency is a available CPU number
76
concurrency: 4
87

9-
# timeout for analysis, e.g. 30s, 5m, default is 1m
10-
timeout: 5m
11-
linters-settings:
12-
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
16-
depguard:
17-
rules:
18-
main:
19-
list-mode: lax # Everything is allowed unless it is denied
20-
deny:
21-
- pkg: "github.com/stretchr/testify"
22-
desc: Do not use a testing framework
23-
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'.
27-
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()
37-
nakedret:
38-
max-func-lines: 0
39-
revive:
40-
ignore-generated-header: true
41-
severity: error
42-
# https://github.com/mgechev/revive
43-
rules:
44-
- name: errorf
45-
- name: context-as-argument
46-
- name: error-return
47-
- name: increment-decrement
48-
- 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
658
linters:
9+
# https://golangci-lint.run/usage/linters/
6610
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
11+
- bodyclose
12+
- depguard
7613
- errorlint
14+
- forcetypeassert
7715
- gochecknoinits
7816
- gocritic
79-
- gofmt
80-
- goimports
8117
- gosec
8218
- misspell
8319
- nakedret
8420
- revive
85-
- depguard
86-
- bodyclose
8721
- sqlclosecheck
8822
- wastedassign
89-
- forcetypeassert
90-
- errcheck
9123
disable:
9224
- noctx # false positive: finds errors with http.NewRequest that dont make sense
9325
- unparam # false positives
94-
issues:
95-
exclude-use-default: false
26+
settings:
27+
depguard:
28+
rules:
29+
main:
30+
list-mode: lax # Everything is allowed unless it is denied
31+
deny:
32+
- pkg: github.com/stretchr/testify
33+
desc: Do not use a testing framework
34+
gocritic:
35+
disabled-checks:
36+
- wrapperFunc
37+
- typeDefFirst
38+
- ifElseChain
39+
- dupImport # https://github.com/go-critic/go-critic/issues/845
40+
enabled-tags:
41+
- performance
42+
- style
43+
- experimental
44+
gosec:
45+
excludes:
46+
# Suppressions: (see https://github.com/securego/gosec#available-rules for details)
47+
- G104 # "Audit errors not checked" -> which we don't need and is a badly implemented version of errcheck
48+
- G102 # "Bind to all interfaces" -> since this is normal in k8s
49+
- G304 # "File path provided as taint input" -> too many false positives
50+
- G307 # "Deferring unsafe method "Close" on type "io.ReadCloser" -> false positive when calling defer resp.Body.Close()
51+
staticcheck:
52+
checks:
53+
# Default:
54+
- all
55+
- "-ST1000" # Incorrect or missing package comment.
56+
- "-ST1003" # Poorly chosen identifier.
57+
- "-ST1016" # Use consistent method receiver names.
58+
- "-ST1020" # The documentation of an exported function should start with the function's name.
59+
- "-ST1021" # The documentation of an exported function should start with the function's name.
60+
- "-ST1022" # The documentation of an exported variable or constant should start with variable's name.
61+
# Custom:
62+
- "-ST1005" # Incorrectly formatted error string.
63+
- "-QF1003" # Convert if/else-if chain to tagged switch.
64+
- "-QF1001" # Apply De Morgan's law.
65+
misspell:
66+
# Correct spellings using locale preferences for US or UK.
67+
# Default is to use a neutral variety of English.
68+
# Setting locale to US will correct the British spelling of 'colour' to 'color'.
69+
locale: US
70+
nakedret:
71+
max-func-lines: 0
72+
revive:
73+
severity: error
74+
# https://github.com/mgechev/revive
75+
rules:
76+
- name: errorf
77+
- name: context-as-argument
78+
- name: error-return
79+
- name: increment-decrement
80+
- name: indent-error-flow
81+
- name: superfluous-else
82+
- name: unused-parameter
83+
- name: unreachable-code
84+
- name: atomic
85+
- name: empty-lines
86+
- name: early-return
87+
exclusions:
88+
generated: lax
89+
paths:
90+
- third_party$
91+
- builtin$
92+
- examples$
93+
formatters:
94+
enable:
95+
- gofmt
96+
- goimports
97+
settings:
98+
goimports:
99+
local-prefixes:
100+
- github.com/freiheit-com/nmww
101+
exclusions:
102+
generated: lax
103+
paths:
104+
- third_party$
105+
- builtin$
106+
- examples$

stackit/internal/services/cdn/distribution/resource.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ type backend struct {
105105
}
106106

107107
type backendCredentials struct {
108-
AccessKey *string `tfsdk:"access_key_id"`
108+
AccessKey *string `tfsdk:"access_key_id"` //nolint:gosec // AccessKey should be exported from this struct
109109
SecretKey *string `tfsdk:"secret_access_key"`
110110
}
111111

stackit/internal/services/dns/dns_acc_test.go

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -116,12 +116,9 @@ func TestAccDnsMinResource(t *testing.T) {
116116
resource.TestCheckResourceAttr("stackit_dns_zone.zone", "project_id", testutil.ProjectId),
117117
resource.TestCheckResourceAttrSet("stackit_dns_zone.zone", "zone_id"),
118118
resource.TestCheckResourceAttrSet("stackit_dns_zone.zone", "state"),
119-
120119
resource.TestCheckResourceAttrSet("stackit_dns_zone.zone", "primary_name_server"),
121120
resource.TestCheckResourceAttrSet("stackit_dns_zone.zone", "serial_number"),
122-
resource.TestCheckResourceAttrSet("stackit_dns_zone.zone", "state"),
123121
resource.TestCheckResourceAttrSet("stackit_dns_zone.zone", "visibility"),
124-
resource.TestCheckResourceAttrSet("stackit_dns_zone.zone", "zone_id"),
125122
// Record set data
126123
resource.TestCheckResourceAttrPair(
127124
"stackit_dns_record_set.record_set", "project_id",
@@ -241,9 +238,7 @@ func TestAccDnsMinResource(t *testing.T) {
241238
resource.TestCheckResourceAttrSet("stackit_dns_zone.zone", "state"),
242239
resource.TestCheckResourceAttrSet("stackit_dns_zone.zone", "primary_name_server"),
243240
resource.TestCheckResourceAttrSet("stackit_dns_zone.zone", "serial_number"),
244-
resource.TestCheckResourceAttrSet("stackit_dns_zone.zone", "state"),
245241
resource.TestCheckResourceAttrSet("stackit_dns_zone.zone", "visibility"),
246-
resource.TestCheckResourceAttrSet("stackit_dns_zone.zone", "zone_id"),
247242
// Record set data
248243
resource.TestCheckResourceAttrPair(
249244
"stackit_dns_record_set.record_set", "project_id",
@@ -305,9 +300,7 @@ func TestAccDnsMaxResource(t *testing.T) {
305300
resource.TestCheckResourceAttr("stackit_dns_zone.zone", "type", testutil.ConvertConfigVariable(testConfigVarsMax["type"])),
306301
resource.TestCheckResourceAttrSet("stackit_dns_zone.zone", "primary_name_server"),
307302
resource.TestCheckResourceAttrSet("stackit_dns_zone.zone", "serial_number"),
308-
resource.TestCheckResourceAttrSet("stackit_dns_zone.zone", "state"),
309303
resource.TestCheckResourceAttrSet("stackit_dns_zone.zone", "visibility"),
310-
resource.TestCheckResourceAttrSet("stackit_dns_zone.zone", "zone_id"),
311304

312305
resource.TestCheckResourceAttrSet("stackit_dns_record_set.record_set", "record_set_id"),
313306
resource.TestCheckResourceAttr("stackit_dns_record_set.record_set", "name", testutil.ConvertConfigVariable(testConfigVarsMax["record_name"])),
@@ -479,9 +472,7 @@ func TestAccDnsMaxResource(t *testing.T) {
479472
resource.TestCheckResourceAttr("stackit_dns_zone.zone", "type", testutil.ConvertConfigVariable(testConfigVarsMax["type"])),
480473
resource.TestCheckResourceAttrSet("stackit_dns_zone.zone", "primary_name_server"),
481474
resource.TestCheckResourceAttrSet("stackit_dns_zone.zone", "serial_number"),
482-
resource.TestCheckResourceAttrSet("stackit_dns_zone.zone", "state"),
483475
resource.TestCheckResourceAttrSet("stackit_dns_zone.zone", "visibility"),
484-
resource.TestCheckResourceAttrSet("stackit_dns_zone.zone", "zone_id"),
485476
// Record set data
486477
resource.TestCheckResourceAttrPair(
487478
"stackit_dns_record_set.record_set", "project_id",

0 commit comments

Comments
 (0)