-
Notifications
You must be signed in to change notification settings - Fork 385
/
Copy path.golangci.yml
130 lines (121 loc) · 4.53 KB
/
.golangci.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
# options for analysis running
run:
timeout: 15m
build-tags:
- hack
tests: true
modules-download-mode: readonly
allow-parallel-runners: true
linters:
enable:
- copyloopvar # Detects unnecessary copies of loop variables for Go >= 1.22
- depguard # Checks if package imports are in a list of acceptable packages
- dupword # Finds word repetitions
- errorlint # Find code that will cause problems with Go's error wrapping scheme
- exptostd # Detects functions from golang.org/x/exp/ that can be replaced by std functions
- gocritic # another style/metalinter (dynamic rules supported)
- gofmt # Checks whether code was gofmt-ed
- goheader # Checks is file headers matche a given pattern
- intrange # Checking for loops that could use an integer range
- nolintlint # Find ill-formed or insufficiently explained nolint directives
- nosprintfhostport # Detects misuses of Sprintf to construct hosts with ports in a URL
- perfsprint # Checks for faster fmt.Sprintf alternatives
- revive # Stricter drop-in replacement for golint
- testifylint # Checks usage of github.com/stretchr/testify
- unconvert # Checks for unnecessary type conversions
- unparam # Checks for unused function parameters
- usestdlibvars # Checks for things that are provided by the standard library
- usetesting # Reports usages of functions that have a replacement within the testing package
linters-settings:
depguard:
rules:
cloud-provider:
list-mode: lax
files:
- "!**/pkg/k0scloudprovider/*.go"
deny:
- pkg: k8s.io/cloud-provider
desc: >-
Usages of the k8s cloud provider are only allowed from within the
k0s cloud provider package. This is to ensure that it's not
leaking global flags into k0s.
replacements:
list-mode: lax
deny:
- pkg: gopkg.in/yaml.v2
desc: Use sigs.k8s.io/yaml.
- pkg: gopkg.in/yaml.v3
desc: Use sigs.k8s.io/yaml.
- pkg: k8s.io/utils/pointer
desc: Use k8s.io/utils/ptr.
tests:
list-mode: lax
files:
- "!$test"
- "!**/internal/testutil/**"
- "!**/internal/autopilot/testutil/**"
- "!**/inttest/**"
deny:
- pkg: github.com/k0sproject/k0s/internal/testutil
desc: Usage of test code outside of tests.
- pkg: github.com/k0sproject/k0s/internal/autopilot/testutil
desc: Usage of test code outside of tests.
- pkg: github.com/stretchr/testify
desc: Usage of test code outside of tests.
inttests:
list-mode: lax
files:
- "!**/inttest/**/*"
deny:
- pkg: github.com/k0sproject/k0s/inttest
desc: Usage of integration test code outside of integration tests.
gocritic:
disabled-checks:
- singleCaseSwitch
settings:
ifElseChain:
minThreshold: 5
goheader:
template-path: .go-header.txt
values:
regexp:
year: 202[0-9]
revive:
rules:
# This forbids to name variables "close", which seems natural for "close" functions.
- name: redefines-builtin-id
disabled: true
testifylint:
enable-all: true
disable:
- require-error # flags too many legitimate use cases
- suite-thelper # flags too many legitimate use cases
issues:
max-issues-per-linter: 0
max-same-issues: 0
exclude-dirs-use-default: false
exclude-dirs:
- build
- docs
- embedded-bins
- examples
exclude-files:
- "zz_*"
exclude-rules:
# https://github.com/denis-tingaikin/go-header/issues/18
# This means that the header checks are ineffective for all files with build tags.
- source: "^//go:build"
linters:
- goheader
# Ignore deprecations: They shouldn't break the CI. If this were the case,
# it would be pointless to have them. There's no way in reporting them as
# warnings without having a non-zero exit code.
# https://github.com/golangci/golangci-lint/pull/3184#issuecomment-1235438429
- linters:
- staticcheck
text: "^SA1019:"
# tcpproxy is copied from https://github.com/inetaf/tcpproxy/, as per
# Apache 2.0 license section 4 (Redistribution) we must keep the original header.
- path: "pkg/component/controller/cplb/tcpproxy/.*"
linters:
- goheader