sigs.k8s.io/cluster-api@v1.7.1/.golangci.yml (about) 1 run: 2 timeout: 10m 3 go: "1.21" 4 build-tags: 5 - tools 6 - e2e 7 skip-files: 8 - "zz_generated.*\\.go$" 9 - "vendored_openapi\\.go$" 10 # We don't want to invest time to fix new linter findings in old API types. 11 - "internal/apis/.*" 12 allow-parallel-runners: true 13 14 linters: 15 disable-all: true 16 enable: 17 - asasalint 18 - asciicheck 19 - bidichk 20 - bodyclose 21 - containedctx 22 - dogsled 23 - dupword 24 - durationcheck 25 - errcheck 26 - errchkjson 27 - exportloopref 28 - gci 29 - ginkgolinter 30 - goconst 31 - gocritic 32 - godot 33 - gofmt 34 - goimports 35 - goprintffuncname 36 - gosec 37 - gosimple 38 - govet 39 - importas 40 - ineffassign 41 - loggercheck 42 - misspell 43 - nakedret 44 - nilerr 45 - noctx 46 - nolintlint 47 - nosprintfhostport 48 - prealloc 49 - predeclared 50 - revive 51 - rowserrcheck 52 - staticcheck 53 - stylecheck 54 - thelper 55 - typecheck 56 - unconvert 57 - unparam 58 - unused 59 - usestdlibvars 60 - whitespace 61 62 linters-settings: 63 gci: 64 sections: 65 - standard # Standard section: captures all standard packages. 66 - default # Default section: contains all imports that could not be matched to another section type. 67 - prefix(sigs.k8s.io/cluster-api) # Custom section: groups all imports with the specified Prefix. 68 custom-order: true 69 ginkgolinter: 70 forbid-focus-container: true 71 godot: 72 # declarations - for top level declaration comments (default); 73 # toplevel - for top level comments; 74 # all - for all comments. 75 scope: toplevel 76 exclude: 77 - '^ \+.*' 78 - '^ ANCHOR.*' 79 gocritic: 80 enabled-tags: 81 - diagnostic 82 - experimental 83 - performance 84 disabled-checks: 85 - appendAssign 86 - dupImport # https://github.com/go-critic/go-critic/issues/845 87 - evalOrder 88 - ifElseChain 89 - octalLiteral 90 - regexpSimplify 91 - sloppyReassign 92 - truncateCmp 93 - typeDefFirst 94 - unnamedResult 95 - unnecessaryDefer 96 - whyNoLint 97 - wrapperFunc 98 - rangeValCopy 99 - hugeParam 100 importas: 101 no-unaliased: true 102 alias: 103 # Kubernetes 104 - pkg: k8s.io/api/core/v1 105 alias: corev1 106 - pkg: k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1 107 alias: apiextensionsv1 108 - pkg: k8s.io/apimachinery/pkg/apis/meta/v1 109 alias: metav1 110 - pkg: k8s.io/apimachinery/pkg/api/errors 111 alias: apierrors 112 - pkg: k8s.io/apimachinery/pkg/util/errors 113 alias: kerrors 114 - pkg: k8s.io/component-base/logs/api/v1 115 alias: logsv1 116 # Controller Runtime 117 - pkg: sigs.k8s.io/controller-runtime 118 alias: ctrl 119 # CABPK 120 - pkg: sigs.k8s.io/cluster-api/internal/apis/bootstrap/kubeadm/v1alpha3 121 alias: bootstrapv1alpha3 122 - pkg: sigs.k8s.io/cluster-api/internal/apis/bootstrap/kubeadm/v1alpha4 123 alias: bootstrapv1alpha4 124 - pkg: sigs.k8s.io/cluster-api/bootstrap/kubeadm/api/v1beta1 125 alias: bootstrapv1 126 # KCP 127 - pkg: sigs.k8s.io/cluster-api/internal/apis/controlplane/kubeadm/v1alpha3 128 alias: controlplanev1alpha3 129 - pkg: sigs.k8s.io/cluster-api/internal/apis/controlplane/kubeadm/v1alpha4 130 alias: controlplanev1alpha4 131 - pkg: sigs.k8s.io/cluster-api/controlplane/kubeadm/api/v1beta1 132 alias: controlplanev1 133 # CAPI 134 - pkg: sigs.k8s.io/cluster-api/internal/apis/core/v1alpha3 135 alias: clusterv1alpha3 136 - pkg: sigs.k8s.io/cluster-api/internal/apis/core/v1alpha4 137 alias: clusterv1alpha4 138 - pkg: sigs.k8s.io/cluster-api/api/v1beta1 139 alias: clusterv1 140 # CAPI exp 141 - pkg: sigs.k8s.io/cluster-api/internal/apis/core/exp/v1alpha3 142 alias: expv1alpha3 143 - pkg: sigs.k8s.io/cluster-api/internal/apis/core/exp/v1alpha4 144 alias: expv1alpha4 145 - pkg: sigs.k8s.io/cluster-api/exp/api/v1beta1 146 alias: expv1 147 # CAPI exp addons 148 - pkg: sigs.k8s.io/cluster-api/internal/apis/core/exp/addons/v1alpha3 149 alias: addonsv1alpha3 150 - pkg: sigs.k8s.io/cluster-api/internal/apis/core/exp/addons/v1alpha4 151 alias: addonsv1alpha4 152 - pkg: sigs.k8s.io/cluster-api/exp/addons/api/v1beta1 153 alias: addonsv1 154 # CAPI exp IPAM 155 - pkg: sigs.k8s.io/cluster-api/exp/ipam/api/v1beta1 156 alias: ipamv1 157 # CAPI exp runtime 158 - pkg: sigs.k8s.io/cluster-api/exp/runtime/api/v1alpha1 159 alias: runtimev1 160 - pkg: sigs.k8s.io/cluster-api/exp/runtime/hooks/api/v1alpha1 161 alias: runtimehooksv1 162 - pkg: sigs.k8s.io/cluster-api/exp/runtime/controllers 163 alias: runtimecontrollers 164 - pkg: sigs.k8s.io/cluster-api/exp/runtime/catalog 165 alias: runtimecatalog 166 - pkg: sigs.k8s.io/cluster-api/internal/runtime/client 167 alias: runtimeclient 168 - pkg: sigs.k8s.io/cluster-api/internal/runtime/registry 169 alias: runtimeregistry 170 - pkg: sigs.k8s.io/cluster-api/internal/webhooks/runtime 171 alias: runtimewebhooks 172 # CAPD 173 - pkg: sigs.k8s.io/cluster-api/test/infrastructure/docker/api/v1alpha3 174 alias: infrav1alpha3 175 - pkg: sigs.k8s.io/cluster-api/test/infrastructure/docker/api/v1alpha4 176 alias: infrav1alpha4 177 - pkg: sigs.k8s.io/cluster-api/test/infrastructure/docker/api/v1beta1 178 alias: infrav1 179 # CAPD exp 180 - pkg: sigs.k8s.io/cluster-api/test/infrastructure/docker/exp/api/v1alpha3 181 alias: infraexpv1alpha3 182 - pkg: sigs.k8s.io/cluster-api/test/infrastructure/docker/exp/api/v1alpha4 183 alias: infraexpv1alpha4 184 - pkg: sigs.k8s.io/cluster-api/test/infrastructure/docker/exp/api/v1beta1 185 alias: infraexpv1 186 nolintlint: 187 allow-unused: false 188 allow-leading-space: false 189 require-specific: true 190 revive: 191 rules: 192 # The following rules are recommended https://github.com/mgechev/revive#recommended-configuration 193 - name: blank-imports 194 - name: context-as-argument 195 - name: context-keys-type 196 - name: dot-imports 197 - name: error-return 198 - name: error-strings 199 - name: error-naming 200 - name: exported 201 - name: if-return 202 - name: increment-decrement 203 - name: var-naming 204 - name: var-declaration 205 - name: package-comments 206 - name: range 207 - name: receiver-naming 208 - name: time-naming 209 - name: unexported-return 210 - name: indent-error-flow 211 - name: errorf 212 - name: empty-block 213 - name: superfluous-else 214 - name: unused-parameter 215 - name: unreachable-code 216 - name: redefines-builtin-id 217 # 218 # Rules in addition to the recommended configuration above. 219 # 220 - name: bool-literal-in-expr 221 - name: constant-logical-expr 222 goconst: 223 ignore-tests: true 224 issues: 225 max-same-issues: 0 226 max-issues-per-linter: 0 227 # We are disabling default golangci exclusions because we want to help reviewers to focus on reviewing the most relevant 228 # changes in PRs and avoid nitpicking. 229 exclude-use-default: false 230 exclude-rules: 231 # Specific exclude rules for deprecated fields that are still part of the codebase. These 232 # should be removed as the referenced deprecated item is removed from the project. 233 - linters: 234 - staticcheck 235 text: "SA1019: (bootstrapv1.ClusterStatus|KubeadmConfigSpec.UseExperimentalRetryJoin|scope.Config.Spec.UseExperimentalRetryJoin|DockerMachine.Spec.Bootstrapped|machineStatus.Bootstrapped|c.TopologyPlan) is deprecated" 236 # Specific exclude rules for deprecated packages that are still part of the codebase. These 237 # should be removed as the referenced deprecated packages are removed from the project. 238 - linters: 239 - staticcheck 240 text: "SA1019: .* is deprecated: This package will be removed in one of the next releases." 241 # Specific exclude rules for deprecated types that are still part of the codebase. These 242 # should be removed as the referenced deprecated types are removed from the project. 243 - linters: 244 - staticcheck 245 text: "SA1019: (clusterv1alpha3.*|clusterv1alpha4.*) is deprecated: This type will be removed in one of the next releases." 246 - linters: 247 - revive 248 text: "exported: exported method .*\\.(Reconcile|SetupWithManager|SetupWebhookWithManager) should have comment or be unexported" 249 - linters: 250 - errcheck 251 text: Error return value of .((os\.)?std(out|err)\..*|.*Close|.*Flush|os\.Remove(All)?|.*print(f|ln)?|os\.(Un)?Setenv). is not checked 252 # Exclude some packages or code to require comments, for example test code, or fake clients. 253 - linters: 254 - revive 255 text: exported (method|function|type|const) (.+) should have comment or be unexported 256 source: (func|type).*Fake.* 257 - linters: 258 - revive 259 text: exported (method|function|type|const) (.+) should have comment or be unexported 260 path: fake_\.go 261 - linters: 262 - revive 263 text: exported (method|function|type|const) (.+) should have comment or be unexported 264 path: cmd/clusterctl/internal/test/providers.*.go 265 - linters: 266 - revive 267 text: exported (method|function|type|const) (.+) should have comment or be unexported 268 path: "(framework|e2e)/.*.go" 269 # Disable unparam "always receives" which might not be really 270 # useful when building libraries. 271 - linters: 272 - unparam 273 text: always receives 274 # Dot imports for gomega and ginkgo are allowed 275 # within test files and test utils. 276 - linters: 277 - revive 278 - stylecheck 279 path: _test\.go 280 text: should not use dot imports 281 - linters: 282 - revive 283 - stylecheck 284 path: (framework|e2e)/.*.go 285 text: should not use dot imports 286 - linters: 287 - revive 288 - stylecheck 289 path: util/defaulting/defaulting.go 290 text: should not use dot imports 291 # Append should be able to assign to a different var/slice. 292 - linters: 293 - gocritic 294 text: "appendAssign: append result not assigned to the same slice" 295 # Disable linters for conversion 296 - linters: 297 - staticcheck 298 text: "SA1019: in.(.+) is deprecated" 299 path: .*(api|types)\/.*\/conversion.*\.go$ 300 - linters: 301 - revive 302 # Checking if an error is nil to just after return the error or nil is redundant 303 text: "if-return: redundant if ...; err != nil check, just return error instead" 304 # Ignoring stylistic checks for generated code 305 path: .*(api|types|test)\/.*\/conversion.*\.go$ 306 - linters: 307 - revive 308 # Exported function and methods should have comments. This warns on undocumented exported functions and methods. 309 text: exported (method|function|type|const) (.+) should have comment or be unexported 310 # Ignoring stylistic checks for generated code 311 path: .*(api|types|test)\/.*\/conversion.*\.go$ 312 - linters: 313 - revive 314 # This rule warns when initialism, variable or package naming conventions are not followed. 315 text: "var-naming: don't use underscores in Go names;" 316 # Ignoring stylistic checks for generated code 317 path: .*(api|types|test)\/.*\/conversion.*\.go$ 318 - linters: 319 - revive 320 # By convention, receiver names in a method should reflect their identity. 321 text: "receiver-naming: receiver name" 322 # Ignoring stylistic checks for generated code 323 path: .*(api|types)\/.*\/conversion.*\.go$ 324 - linters: 325 - stylecheck 326 text: "ST1003: should not use underscores in Go names;" 327 path: .*(api|types|test)\/.*\/conversion.*\.go$ 328 - linters: 329 - stylecheck 330 text: "ST1016: methods on the same type should have the same receiver name" 331 path: .*(api|types)\/.*\/conversion.*\.go$ 332 # We don't care about defer in for loops in test files. 333 - linters: 334 - gocritic 335 text: "deferInLoop: Possible resource leak, 'defer' is called in the 'for' loop" 336 path: _test\.go