github.com/m3db/m3@v1.5.0/.golangci.yml (about) 1 # options for analysis running 2 run: 3 # default concurrency is a available CPU number 4 # concurrency: 4 5 6 # timeout for analysis, e.g. 30s, 5m, default is 1m 7 deadline: 10m 8 9 # exit code when at least one issue was found, default is 1 10 issues-exit-code: 1 11 12 # include test files or not, default is true 13 tests: true 14 15 # list of build tags, all linters use it. Default is empty list. 16 build-tags: 17 - big 18 - compatibility 19 - dtest 20 - integration 21 22 # which dirs to skip: they won't be analyzed; 23 # can use regexp here: generated.*, regexp is applied on full path; 24 # default value is empty list, but next dirs are always skipped independently 25 # from this option's value: 26 # vendor$, third_party$, testdata$, examples$, Godeps$, builtin$ 27 skip-dirs: 28 - generated/.* 29 # There is some very weird golangci-lint bug that causes analysis to fail on the 30 # eventlog_server_test.go file (perhaps caused by https://github.com/golangci/golangci-lint/issues/995). 31 # To avoid sporadic CI failures we exclude the file from analysis for the time being. 32 # In order to exclude the file from analysis, and not just any lints in it, we need 33 # to put the file in a separate directory since although golangci-lint skips issues 34 # from files in the skip-files list, it still runs analysis on them. 35 - eventlog/test$ 36 37 # which files to skip: they will be analyzed, but issues from them 38 # won't be reported. Default value is empty list, but there is 39 # no need to include all autogenerated files, we confidently recognize 40 # autogenerated files. If it's not please let us know. 41 skip-files: 42 - ".*_gen.go$" 43 44 # by default isn't set. If set we pass it to "go list -mod={option}". From "go help modules": 45 # If invoked with -mod=readonly, the go command is disallowed from the implicit 46 # automatic updating of go.mod described above. Instead, it fails when any changes 47 # to go.mod are needed. This setting is most useful to check that go.mod does 48 # not need updates, such as in a continuous integration and testing system. 49 # If invoked with -mod=vendor, the go command assumes that the vendor 50 # directory holds the correct copies of dependencies and ignores 51 # the dependency descriptions in go.mod. 52 # modules-download-mode: readonly|release|vendor 53 modules-download-mode: readonly 54 55 56 # output configuration options 57 output: 58 # colored-line-number|line-number|json|tab|checkstyle|code-climate, default is "colored-line-number" 59 format: colored-line-number 60 61 # print lines of code with issue, default is true 62 print-issued-lines: true 63 64 # print linter name in the end of issue text, default is true 65 print-linter-name: true 66 67 68 # all available settings of specific linters 69 linters-settings: 70 govet: 71 # report about shadowed variables 72 check-shadowing: true 73 goimports: 74 # put imports beginning with prefix after 3rd-party packages; 75 # it's a comma-separated list of prefixes 76 local-prefixes: github.com/m3db/m3 77 maligned: 78 # print struct with more effective memory layout or not, false by default 79 suggest-new: true 80 dupl: 81 # tokens count to trigger issue, 150 by default 82 threshold: 100 83 goconst: 84 # minimal length of string constant, 3 by default 85 min-len: 3 86 # minimal occurrences count to trigger, 3 by default 87 min-occurrences: 3 88 depguard: 89 list-type: blacklist 90 include-go-root: false 91 packages: 92 - github.com/sirupsen/logrus 93 - github.com/golang/protobuf/jsonpb 94 - google.golang.org/protobuf/encoding/protojson 95 - github.com/golang/protobuf/proto 96 - google.golang.org/protobuf/proto 97 - github.com/tj/assert 98 packages-with-error-messages: 99 # specify an error message to output when a blacklisted package is used 100 github.com/sirupsen/logrus: "logging is allowed only by logutils.Log" 101 github.com/golang/protobuf/jsonpb: "replace with github.com/gogo/protobuf/jsonpb" 102 google.golang.org/protobuf/encoding/protojson: "replace with github.com/gogo/protobuf/jsonpb" 103 github.com/golang/protobuf/proto: "replace with github.com/gogo/protobuf/proto" 104 google.golang.org/protobuf/proto: "replace with github.com/gogo/protobuf/proto" 105 github.com/tj/assert: "use github.com/stretchr/testify/assert" 106 misspell: 107 # Correct spellings using locale preferences for US or UK. 108 # Default is to use a neutral variety of English. 109 # Setting locale to US will correct the British spelling of 'colour' to 'color'. 110 locale: US 111 ignore-words: 112 - someword 113 exhaustive: 114 default-signifies-exhaustive: true 115 lll: 116 # max line length, lines longer will be reported. Default is 120. 117 # '\t' is counted as 1 character by default, and can be changed with the tab-width option 118 line-length: 120 119 # tab width in spaces. Default to 1. 120 tab-width: 1 121 unused: 122 # treat code as a program (not a library) and report unused exported identifiers; default is false. 123 # XXX: if you enable this setting, unused will report a lot of false-positives in text editors: 124 # if it's called for subdir of a project it can't find funcs usages. All text editor integrations 125 # with golangci-lint call it on a directory with the changed file. 126 check-exported: false 127 unparam: 128 # Inspect exported functions, default is false. Set to true if no external program/library imports your code. 129 # XXX: if you enable this setting, unparam will report a lot of false-positives in text editors: 130 # if it's called for subdir of a project it can't find external interfaces. All text editor integrations 131 # with golangci-lint call it on a directory with the changed file. 132 check-exported: false 133 nakedret: 134 # make an issue if func has more lines of code than this setting and it has naked returns; default is 30 135 max-func-lines: 30 136 prealloc: 137 # XXX: we don't recommend using this linter before doing performance profiling. 138 # For most programs usage of prealloc will be a premature optimization. 139 140 # Report preallocation suggestions only on simple loops that have no returns/breaks/continues/gotos in them. 141 # True by default. 142 simple: true 143 range-loops: true # Report preallocation suggestions on range loops, true by default 144 for-loops: false # Report preallocation suggestions on for loops, false by default 145 gocritic: 146 # Which checks should be enabled; can't be combined with 'disabled-checks'; 147 # See https://go-critic.github.io/overview#checks-overview 148 # To check which checks are enabled run `GL_DEBUG=gocritic golangci-lint run` 149 # By default list of stable checks is used. 150 151 # Enable multiple checks by tags, run `GL_DEBUG=gocritic golangci-lint` run to see all tags and checks. 152 # Empty list by default. See https://github.com/go-critic/go-critic#usage -> section "Tags". 153 enabled-tags: 154 - performance 155 disabled-checks: 156 # These both suggest using pointers for large value structs 157 # but cause significant heap allocations in place which causes 158 # fairly heap allocations. Better to pay fast memcpy and rely 159 # on the stack being cheap to allocate than use heap allocations 160 # as a general rule of thumb. 161 - hugeParam 162 - rangeValCopy 163 enabled-checks: 164 - ruleguard 165 settings: # settings passed to gocritic 166 captLocal: # must be valid enabled check name 167 paramsOnly: true 168 ruleguard: 169 rules: "src/cmd/tools/linter/gorules/rules.go" 170 gci: 171 # gci control golang package import order and make it always deterministic 172 local-prefixes: github.com/m3db/m3 173 174 linters: 175 enable: 176 - deadcode 177 - dupl 178 - errcheck 179 - exhaustive 180 - gci 181 - goconst 182 - gocritic 183 - goimports 184 - golint 185 - gosimple 186 - govet 187 - ineffassign 188 - lll 189 - maligned 190 - megacheck 191 - misspell 192 - prealloc 193 - staticcheck 194 - structcheck 195 - typecheck 196 - unconvert 197 - unparam 198 - varcheck 199 enable-all: false 200 disable: 201 - gomnd 202 - gochecknoinits 203 # Globals gonna global 204 - gochecknoglobals 205 # Overly harsh about long functions 206 - funlen 207 # Linter that checks that every comment ends in a period. 208 - godot 209 # Linter that makes you always use _test packages. 210 - testpackage 211 # Overly opinionated about how to construct errors 212 - goerr113 213 # Noisy warnings about whether "nolint" directives are necessary 214 - nolintlint 215 # Deprecated project due to being prone to bad suggestions. 216 - interfacer 217 # Valid use for not explicitly setting every field when they are optional nil/empty. 218 - exhaustivestruct 219 # We allow cuddling assignment following conditions because there are valid 220 # logical groupings for this use-case (e.g. when evaluating config values). 221 - wsl 222 # Wrapcheck can cause errors until all callsites checking explicit error 223 # types like io.EOF are converted to use errors.Is instead. Re-enable this 224 # linter once all error checks are upgraded. 225 - wrapcheck 226 # godox prevents using TODOs or FIXMEs which can be useful for demarkation 227 # of future work. 228 - godox 229 # New line required before return would require a large fraction of the 230 # code base to need updating, it's not worth the perceived benefit. 231 - nlreturn 232 # Opinionated and sometimes wrong. 233 - paralleltest 234 # Disabled dogsled as using _, _, _ is useful in tests. 235 - dogsled 236 # There are functions with complexity required. 237 - gocyclo 238 # Doesn't buy us much being super opinionated on how to name test functions. 239 - thelper 240 disable-all: false 241 presets: 242 # bodyclose, errcheck, gosec, govet, scopelint, staticcheck, typecheck 243 - bugs 244 # deadcode, ineffassign, structcheck, unparam, unused, varcheck 245 - unused 246 # gofmt, goimports 247 - format 248 # depguard, dupl, gochecknoglobals, gochecknoinits, goconst, gocritic, 249 # golint, gosimple, interfacer, lll, misspell, stylecheck, unconvert 250 - style 251 fast: false 252 253 254 issues: 255 # List of regexps of issue texts to exclude, empty list by default. 256 # But independently from this option we use default exclude patterns, 257 # it can be disabled by `exclude-use-default: false`. To list all 258 # excluded by default patterns execute `golangci-lint run --help` 259 exclude: 260 # Exclude table-driven tests from scopelint (https://github.com/golangci/golangci-lint/issues/281). 261 - "Using the variable on range scope `tt` in function literal" 262 - "Using the variable on range scope `test` in function literal" 263 # It's common to shadow `err` and rarely indicates a problems. See 264 # https://github.com/golang/go/issues/19490 for further details. 265 - 'shadow: declaration of "err" shadows declaration' 266 # We commonly expose profiling information on /debug/pprof so we need to disable the gosec 267 # lint for it. 268 - "Profiling endpoint is automatically exposed on /debug/pprof" 269 # We only use md5 for non-cryptographic purposes (e.g. generating ID's where we don't assume 270 # the ID's are cryptographicly secure). 271 - "Blacklisted import `crypto/md5`: weak cryptographic primitive" 272 # The logger is often our last option to communicate that an error occurred so if it returns 273 # an error we don't have an alternative to use. Since it's already unlikely that `Log` will 274 # return an error anyway we often skip checking the error for brevity. 275 - "Error return value of `\\(github.com\\/go-kit\\/kit\\/log.Logger\\).Log` is not checked" 276 # The caller is responsible for closing the Body of an `http.Response`. However, this step 277 # is usually performed in a defer function after the response has already been processed and 278 # so errors, which are already rare, can usually be safely ignored. 279 - "Error return value of `[a-zA-Z.]+.Body.Close` is not checked" 280 # The errcheck linter already checks for unhandled errors so we can disable the equivalent 281 # lint by gosec. 282 - "G104: Errors unhandled" 283 284 # Excluding configuration per-path, per-linter, per-text and per-source 285 exclude-rules: 286 # Exclude lll issues for long lines with go:generate 287 - linters: 288 - lll 289 source: "^//go:generate " 290 # Exclude some linters from running on tests files. 291 # - path: _test\.go 292 # linters: 293 # - gocyclo 294 # - errcheck 295 # - dupl 296 # - gosec 297 298 299 # Independently from option `exclude` we use default exclude patterns, 300 # it can be disabled by this option. To list all 301 # excluded by default patterns execute `golangci-lint run --help`. 302 # Default value for this option is true. 303 exclude-use-default: false 304 305 # Maximum issues count per one linter. Set to 0 to disable. Default is 50. 306 max-issues-per-linter: 0 307 308 # Maximum count of issues with the same text. Set to 0 to disable. Default is 3. 309 max-same-issues: 0 310 311 # Show only new issues created after git revision `REV` 312 new-from-rev: 30e1c10d456af9d3778288cfb7c247ecd06a4339