|
| 1 | +linters: |
| 2 | + disable-all: true |
| 3 | + enable: |
| 4 | + - asasalint |
| 5 | + - asciicheck |
| 6 | + - bodyclose |
| 7 | + - containedctx |
| 8 | + - copyloopvar |
| 9 | + - decorder |
| 10 | + - dogsled |
| 11 | + - errcheck |
| 12 | + - errchkjson |
| 13 | + - execinquery |
| 14 | + # - gci |
| 15 | + - goconst |
| 16 | + # - gocritic |
| 17 | + - gocyclo |
| 18 | + - godot |
| 19 | + - gofmt |
| 20 | + - goimports |
| 21 | + - goprintffuncname |
| 22 | + # - gosec |
| 23 | + - gosimple |
| 24 | + - govet |
| 25 | + # - importas |
| 26 | + - ineffassign |
| 27 | + - misspell |
| 28 | + - nakedret |
| 29 | + - nilerr |
| 30 | + - noctx |
| 31 | + - nolintlint |
| 32 | + - nosprintfhostport |
| 33 | + - prealloc |
| 34 | + - predeclared |
| 35 | + - reassign |
| 36 | + # - revive |
| 37 | + - rowserrcheck |
| 38 | + - staticcheck |
| 39 | + # - stylecheck |
| 40 | + # - thelper |
| 41 | + - typecheck |
| 42 | + - unconvert |
| 43 | + - unparam |
| 44 | + - unused |
| 45 | + - usestdlibvars |
| 46 | + - whitespace |
| 47 | + |
| 48 | +linters-settings: |
| 49 | + gocyclo: |
| 50 | + min-complexity: 20 |
| 51 | + godot: |
| 52 | + # declarations - for top level declaration comments (default); |
| 53 | + # toplevel - for top level comments; |
| 54 | + # all - for all comments. |
| 55 | + scope: toplevel |
| 56 | + exclude: |
| 57 | + - '^ \+.*' |
| 58 | + - '^ ANCHOR.*' |
| 59 | + gci: |
| 60 | + sections: |
| 61 | + - standard |
| 62 | + - default |
| 63 | + - prefix(github.com/IBM) |
| 64 | + - prefix(k8s.io) |
| 65 | + - prefix(sigs.k8s.io) |
| 66 | + - blank |
| 67 | + - dot |
| 68 | + importas: |
| 69 | + no-unaliased: true |
| 70 | + alias: |
| 71 | + # Kubernetes |
| 72 | + - pkg: k8s.io/api/core/v1 |
| 73 | + alias: corev1 |
| 74 | + - pkg: k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1 |
| 75 | + alias: apiextensionsv1 |
| 76 | + - pkg: k8s.io/apimachinery/pkg/apis/meta/v1 |
| 77 | + alias: metav1 |
| 78 | + - pkg: k8s.io/apimachinery/pkg/api/errors |
| 79 | + alias: apierrors |
| 80 | + - pkg: k8s.io/apimachinery/pkg/util/errors |
| 81 | + alias: kerrors |
| 82 | + # Controller Runtime |
| 83 | + - pkg: sigs.k8s.io/controller-runtime |
| 84 | + alias: ctrl |
| 85 | + nolintlint: |
| 86 | + allow-unused: false |
| 87 | + # allow-leading-space: false |
| 88 | + require-specific: true |
| 89 | + gosec: |
| 90 | + excludes: |
| 91 | + - G307 # Deferring unsafe method "Close" on type "\*os.File" |
| 92 | + - G108 # Profiling endpoint is automatically exposed on /debug/pprof |
| 93 | + gocritic: |
| 94 | + enabled-tags: |
| 95 | + - experimental |
| 96 | + disabled-checks: |
| 97 | + - appendAssign |
| 98 | + - dupImport # https://github.com/go-critic/go-critic/issues/845 |
| 99 | + - evalOrder |
| 100 | + - ifElseChain |
| 101 | + - octalLiteral |
| 102 | + - regexpSimplify |
| 103 | + - sloppyReassign |
| 104 | + - truncateCmp |
| 105 | + - typeDefFirst |
| 106 | + - unnamedResult |
| 107 | + - unnecessaryDefer |
| 108 | + - whyNoLint |
| 109 | + - wrapperFunc |
| 110 | + unused: |
| 111 | + go: "1.23" |
| 112 | +issues: |
| 113 | + exclude-files: |
| 114 | + - "zz_generated.*\\.go$" |
| 115 | + max-same-issues: 0 |
| 116 | + max-issues-per-linter: 0 |
| 117 | + # We are disabling default golangci exclusions because we want to help reviewers to focus on reviewing the most relevant |
| 118 | + # changes in PRs and avoid nitpicking. |
| 119 | + exclude-use-default: false |
| 120 | + exclude-rules: |
| 121 | + - linters: |
| 122 | + - gci |
| 123 | + path: _test\.go |
| 124 | + - linters: |
| 125 | + - revive |
| 126 | + text: "exported: exported method .*\\.(Reconcile|SetupWithManager|SetupWebhookWithManager) should have comment or be unexported" |
| 127 | + - linters: |
| 128 | + - errcheck |
| 129 | + text: Error return value of .((os\.)?std(out|err)\..*|.*Close|.*Flush|os\.Remove(All)?|.*print(f|ln)?|os\.(Un)?Setenv). is not checked |
| 130 | + # Exclude some packages or code to require comments, for example test code, or fake clients. |
| 131 | + - linters: |
| 132 | + - revive |
| 133 | + text: exported (method|function|type|const) (.+) should have comment or be unexported |
| 134 | + source: (func|type).*Fake.* |
| 135 | + - linters: |
| 136 | + - revive |
| 137 | + text: exported (method|function|type|const) (.+) should have comment or be unexported |
| 138 | + path: fake_\.go |
| 139 | + - linters: |
| 140 | + - revive |
| 141 | + text: exported (method|function|type|const) (.+) should have comment or be unexported |
| 142 | + path: "(framework|e2e)/.*.go" |
| 143 | + # Disable unparam "always receives" which might not be really |
| 144 | + # useful when building libraries. |
| 145 | + - linters: |
| 146 | + - unparam |
| 147 | + text: always receives |
| 148 | + # Dot imports for gomega or ginkgo are allowed |
| 149 | + # within test files. |
| 150 | + - path: _test\.go |
| 151 | + text: should not use dot imports |
| 152 | + - path: (framework|e2e)/.*.go |
| 153 | + text: should not use dot imports |
| 154 | + - path: _test\.go |
| 155 | + text: cyclomatic complexity |
| 156 | + # Append should be able to assign to a different var/slice. |
| 157 | + - linters: |
| 158 | + - gocritic |
| 159 | + text: "appendAssign: append result not assigned to the same slice" |
| 160 | + # Disable linters for conversion |
| 161 | + - linters: |
| 162 | + - staticcheck |
| 163 | + text: "SA1019: in.(.+) is deprecated" |
| 164 | + path: .*(api|types)\/.*\/.*conversion.*\.go$ |
| 165 | + - linters: |
| 166 | + - revive |
| 167 | + text: exported (method|function|type|const) (.+) should have comment or be unexported |
| 168 | + path: .*(api|types)\/.*\/.*conversion.*\.go$ |
| 169 | + - linters: |
| 170 | + - revive |
| 171 | + text: "var-naming: don't use underscores in Go names;" |
| 172 | + path: .*(api|types)\/.*\/.*conversion.*\.go$ |
| 173 | + - linters: |
| 174 | + - revive |
| 175 | + text: "receiver-naming: receiver name" |
| 176 | + path: .*(api|types)\/.*\/.*conversion.*\.go$ |
| 177 | + - linters: |
| 178 | + - stylecheck |
| 179 | + text: "ST1003: should not use underscores in Go names;" |
| 180 | + path: .*(api|types)\/.*\/.*conversion.*\.go$ |
| 181 | + - linters: |
| 182 | + - stylecheck |
| 183 | + text: "ST1016: methods on the same type should have the same receiver name" |
| 184 | + path: .*(api|types)\/.*\/.*conversion.*\.go$ |
| 185 | + # hack/tools |
| 186 | + - linters: |
| 187 | + - typecheck |
| 188 | + text: import (".+") is a program, not an importable package |
| 189 | + path: ^tools\.go$ |
| 190 | + # We don't care about defer in for loops in test files. |
| 191 | + - linters: |
| 192 | + - gocritic |
| 193 | + text: "deferInLoop: Possible resource leak, 'defer' is called in the 'for' loop" |
| 194 | + path: _test\.go |
| 195 | + |
| 196 | +run: |
| 197 | + timeout: 10m |
| 198 | + build-tags: |
| 199 | + - tools |
| 200 | + - e2e |
| 201 | + allow-parallel-runners: true |
| 202 | + go: "1.23" |
0 commit comments