2019-04-24 12:18:40 +00:00
|
|
|
run:
|
2023-04-09 07:08:40 +00:00
|
|
|
timeout: 15m
|
2019-04-24 12:18:40 +00:00
|
|
|
|
2021-11-10 09:29:12 +00:00
|
|
|
output:
|
|
|
|
sort-results: true
|
|
|
|
|
2020-03-23 14:32:37 +00:00
|
|
|
linters:
|
|
|
|
enable:
|
2021-06-12 10:47:47 +00:00
|
|
|
- depguard
|
2023-09-27 21:34:18 +00:00
|
|
|
- errorlint
|
2023-04-09 07:08:40 +00:00
|
|
|
- gocritic
|
2023-10-03 20:09:25 +00:00
|
|
|
- godot
|
2021-10-22 08:27:37 +00:00
|
|
|
- gofumpt
|
|
|
|
- goimports
|
2022-03-03 17:11:19 +00:00
|
|
|
- misspell
|
2023-10-31 11:35:13 +00:00
|
|
|
- nolintlint
|
2024-05-13 15:36:19 +00:00
|
|
|
- perfsprint
|
2023-05-21 07:20:07 +00:00
|
|
|
- predeclared
|
|
|
|
- revive
|
2023-12-07 11:35:01 +00:00
|
|
|
- testifylint
|
2023-04-09 07:08:40 +00:00
|
|
|
- unconvert
|
|
|
|
- unused
|
2024-04-08 19:26:23 +00:00
|
|
|
- usestdlibvars
|
2024-04-11 08:27:54 +00:00
|
|
|
- whitespace
|
2024-06-18 18:41:26 +00:00
|
|
|
- loggercheck
|
2024-09-10 01:41:53 +00:00
|
|
|
- sloglint
|
2020-03-23 14:32:37 +00:00
|
|
|
|
2019-05-03 13:11:28 +00:00
|
|
|
issues:
|
lint: Revamp our linting rules, mostly around doc comments
Several things done here:
- Set `max-issues-per-linter` to 0 so that we actually see all linter
warnings and not just 50 per linter. (As we also set
`max-same-issues` to 0, I assume this was the intention from the
beginning.)
- Stop using the golangci-lint default excludes (by setting
`exclude-use-default: false`. Those are too generous and don't match
our style conventions. (I have re-added some of the excludes
explicitly in this commit. See below.)
- Re-add the `errcheck` exclusion we have used so far via the
defaults.
- Exclude the signature requirement `govet` has for `Seek` methods
because we use non-standard `Seek` methods a lot. (But we keep other
requirements, while the default excludes completely disabled the
check for common method segnatures.)
- Exclude warnings about missing doc comments on exported symbols. (We
used to be pretty adamant about doc comments, but stopped that at
some point in the past. By now, we have about 500 missing doc
comments. We may consider reintroducing this check, but that's
outside of the scope of this commit. The default excludes of
golangci-lint essentially ignore doc comments completely.)
- By stop using the default excludes, we now get warnings back on
malformed doc comments. That's the most impactful change in this
commit. It does not enforce doc comments (again), but _if_ there is
a doc comment, it has to have the recommended form. (Most of the
changes in this commit are fixing this form.)
- Improve wording/spelling of some comments in .golangci.yml, and
remove an outdated comment.
- Leave `package-comments` inactive, but add a TODO asking if we
should change that.
- Add a new sub-linter `comment-spacings` (and fix corresponding
comments), which avoids missing spaces after the leading `//`.
Signed-off-by: beorn7 <beorn@grafana.com>
2024-08-22 11:59:36 +00:00
|
|
|
max-issues-per-linter: 0
|
2022-04-27 09:24:36 +00:00
|
|
|
max-same-issues: 0
|
lint: Revamp our linting rules, mostly around doc comments
Several things done here:
- Set `max-issues-per-linter` to 0 so that we actually see all linter
warnings and not just 50 per linter. (As we also set
`max-same-issues` to 0, I assume this was the intention from the
beginning.)
- Stop using the golangci-lint default excludes (by setting
`exclude-use-default: false`. Those are too generous and don't match
our style conventions. (I have re-added some of the excludes
explicitly in this commit. See below.)
- Re-add the `errcheck` exclusion we have used so far via the
defaults.
- Exclude the signature requirement `govet` has for `Seek` methods
because we use non-standard `Seek` methods a lot. (But we keep other
requirements, while the default excludes completely disabled the
check for common method segnatures.)
- Exclude warnings about missing doc comments on exported symbols. (We
used to be pretty adamant about doc comments, but stopped that at
some point in the past. By now, we have about 500 missing doc
comments. We may consider reintroducing this check, but that's
outside of the scope of this commit. The default excludes of
golangci-lint essentially ignore doc comments completely.)
- By stop using the default excludes, we now get warnings back on
malformed doc comments. That's the most impactful change in this
commit. It does not enforce doc comments (again), but _if_ there is
a doc comment, it has to have the recommended form. (Most of the
changes in this commit are fixing this form.)
- Improve wording/spelling of some comments in .golangci.yml, and
remove an outdated comment.
- Leave `package-comments` inactive, but add a TODO asking if we
should change that.
- Add a new sub-linter `comment-spacings` (and fix corresponding
comments), which avoids missing spaces after the leading `//`.
Signed-off-by: beorn7 <beorn@grafana.com>
2024-08-22 11:59:36 +00:00
|
|
|
# The default exclusions are too aggressive. For one, they
|
|
|
|
# essentially disable any linting on doc comments. We disable
|
|
|
|
# default exclusions here and add exclusions fitting our codebase
|
|
|
|
# further down.
|
|
|
|
exclude-use-default: false
|
2024-07-14 12:02:13 +00:00
|
|
|
exclude-files:
|
|
|
|
# Skip autogenerated files.
|
|
|
|
- ^.*\.(pb|y)\.go$
|
|
|
|
exclude-dirs:
|
lint: Revamp our linting rules, mostly around doc comments
Several things done here:
- Set `max-issues-per-linter` to 0 so that we actually see all linter
warnings and not just 50 per linter. (As we also set
`max-same-issues` to 0, I assume this was the intention from the
beginning.)
- Stop using the golangci-lint default excludes (by setting
`exclude-use-default: false`. Those are too generous and don't match
our style conventions. (I have re-added some of the excludes
explicitly in this commit. See below.)
- Re-add the `errcheck` exclusion we have used so far via the
defaults.
- Exclude the signature requirement `govet` has for `Seek` methods
because we use non-standard `Seek` methods a lot. (But we keep other
requirements, while the default excludes completely disabled the
check for common method segnatures.)
- Exclude warnings about missing doc comments on exported symbols. (We
used to be pretty adamant about doc comments, but stopped that at
some point in the past. By now, we have about 500 missing doc
comments. We may consider reintroducing this check, but that's
outside of the scope of this commit. The default excludes of
golangci-lint essentially ignore doc comments completely.)
- By stop using the default excludes, we now get warnings back on
malformed doc comments. That's the most impactful change in this
commit. It does not enforce doc comments (again), but _if_ there is
a doc comment, it has to have the recommended form. (Most of the
changes in this commit are fixing this form.)
- Improve wording/spelling of some comments in .golangci.yml, and
remove an outdated comment.
- Leave `package-comments` inactive, but add a TODO asking if we
should change that.
- Add a new sub-linter `comment-spacings` (and fix corresponding
comments), which avoids missing spaces after the leading `//`.
Signed-off-by: beorn7 <beorn@grafana.com>
2024-08-22 11:59:36 +00:00
|
|
|
# Copied it from a different source.
|
2024-07-14 12:02:13 +00:00
|
|
|
- storage/remote/otlptranslator/prometheusremotewrite
|
|
|
|
- storage/remote/otlptranslator/prometheus
|
2019-05-03 13:11:28 +00:00
|
|
|
exclude-rules:
|
lint: Revamp our linting rules, mostly around doc comments
Several things done here:
- Set `max-issues-per-linter` to 0 so that we actually see all linter
warnings and not just 50 per linter. (As we also set
`max-same-issues` to 0, I assume this was the intention from the
beginning.)
- Stop using the golangci-lint default excludes (by setting
`exclude-use-default: false`. Those are too generous and don't match
our style conventions. (I have re-added some of the excludes
explicitly in this commit. See below.)
- Re-add the `errcheck` exclusion we have used so far via the
defaults.
- Exclude the signature requirement `govet` has for `Seek` methods
because we use non-standard `Seek` methods a lot. (But we keep other
requirements, while the default excludes completely disabled the
check for common method segnatures.)
- Exclude warnings about missing doc comments on exported symbols. (We
used to be pretty adamant about doc comments, but stopped that at
some point in the past. By now, we have about 500 missing doc
comments. We may consider reintroducing this check, but that's
outside of the scope of this commit. The default excludes of
golangci-lint essentially ignore doc comments completely.)
- By stop using the default excludes, we now get warnings back on
malformed doc comments. That's the most impactful change in this
commit. It does not enforce doc comments (again), but _if_ there is
a doc comment, it has to have the recommended form. (Most of the
changes in this commit are fixing this form.)
- Improve wording/spelling of some comments in .golangci.yml, and
remove an outdated comment.
- Leave `package-comments` inactive, but add a TODO asking if we
should change that.
- Add a new sub-linter `comment-spacings` (and fix corresponding
comments), which avoids missing spaces after the leading `//`.
Signed-off-by: beorn7 <beorn@grafana.com>
2024-08-22 11:59:36 +00:00
|
|
|
- linters:
|
|
|
|
- errcheck
|
|
|
|
# Taken from the default exclusions (that are otherwise disabled above).
|
|
|
|
text: Error return value of .((os\.)?std(out|err)\..*|.*Close|.*Flush|os\.Remove(All)?|.*print(f|ln)?|os\.(Un)?Setenv). is not checked
|
|
|
|
- linters:
|
|
|
|
- govet
|
|
|
|
# We use many Seek methods that do not follow the usual pattern.
|
|
|
|
text: "stdmethods: method Seek.* should have signature Seek"
|
|
|
|
- linters:
|
|
|
|
- revive
|
|
|
|
# We have stopped at some point to write doc comments on exported symbols.
|
|
|
|
# TODO(beorn7): Maybe we should enforce this again? There are ~500 offenders right now.
|
|
|
|
text: exported (.+) should have comment( \(or a comment on this block\))? or be unexported
|
2023-04-09 07:08:40 +00:00
|
|
|
- linters:
|
|
|
|
- gocritic
|
|
|
|
text: "appendAssign"
|
2021-06-12 10:47:47 +00:00
|
|
|
- path: _test.go
|
|
|
|
linters:
|
|
|
|
- errcheck
|
2023-11-16 18:54:41 +00:00
|
|
|
- path: "tsdb/head_wal.go"
|
2023-09-27 21:34:18 +00:00
|
|
|
linters:
|
|
|
|
- errorlint
|
2023-10-03 20:09:25 +00:00
|
|
|
- linters:
|
|
|
|
- godot
|
|
|
|
source: "^// ==="
|
2024-05-13 15:36:19 +00:00
|
|
|
- linters:
|
|
|
|
- perfsprint
|
2024-05-27 19:57:45 +00:00
|
|
|
text: "fmt.Sprintf can be replaced with string concatenation"
|
2019-05-03 13:11:28 +00:00
|
|
|
linters-settings:
|
2020-08-21 09:37:21 +00:00
|
|
|
depguard:
|
2023-06-27 11:51:29 +00:00
|
|
|
rules:
|
|
|
|
main:
|
|
|
|
deny:
|
2024-03-21 03:32:02 +00:00
|
|
|
- pkg: "sync/atomic"
|
|
|
|
desc: "Use go.uber.org/atomic instead of sync/atomic"
|
|
|
|
- pkg: "github.com/stretchr/testify/assert"
|
|
|
|
desc: "Use github.com/stretchr/testify/require instead of github.com/stretchr/testify/assert"
|
|
|
|
- pkg: "github.com/go-kit/kit/log"
|
|
|
|
desc: "Use github.com/go-kit/log instead of github.com/go-kit/kit/log"
|
|
|
|
- pkg: "io/ioutil"
|
|
|
|
desc: "Use corresponding 'os' or 'io' functions instead."
|
|
|
|
- pkg: "regexp"
|
|
|
|
desc: "Use github.com/grafana/regexp instead of regexp"
|
|
|
|
- pkg: "github.com/pkg/errors"
|
|
|
|
desc: "Use 'errors' or 'fmt' instead of github.com/pkg/errors"
|
|
|
|
- pkg: "gzip"
|
|
|
|
desc: "Use github.com/klauspost/compress instead of gzip"
|
|
|
|
- pkg: "zlib"
|
|
|
|
desc: "Use github.com/klauspost/compress instead of zlib"
|
|
|
|
- pkg: "golang.org/x/exp/slices"
|
|
|
|
desc: "Use 'slices' instead."
|
2019-05-03 13:11:28 +00:00
|
|
|
errcheck:
|
2023-04-03 07:05:10 +00:00
|
|
|
exclude-functions:
|
|
|
|
# Don't flag lines such as "io.Copy(io.Discard, resp.Body)".
|
|
|
|
- io.Copy
|
|
|
|
# The next two are used in HTTP handlers, any error is handled by the server itself.
|
|
|
|
- io.WriteString
|
|
|
|
- (net/http.ResponseWriter).Write
|
|
|
|
# No need to check for errors on server's shutdown.
|
|
|
|
- (*net/http.Server).Shutdown
|
|
|
|
# Never check for rollback errors as Rollback() is called when a previous error was detected.
|
|
|
|
- (github.com/prometheus/prometheus/storage.Appender).Rollback
|
2021-10-22 08:27:37 +00:00
|
|
|
goimports:
|
|
|
|
local-prefixes: github.com/prometheus/prometheus
|
|
|
|
gofumpt:
|
|
|
|
extra-rules: true
|
2024-05-13 15:36:19 +00:00
|
|
|
perfsprint:
|
|
|
|
# Optimizes `fmt.Errorf`.
|
|
|
|
errorf: false
|
2023-04-04 08:28:19 +00:00
|
|
|
revive:
|
2023-11-29 17:23:34 +00:00
|
|
|
# By default, revive will enable only the linting rules that are named in the configuration file.
|
lint: Revamp our linting rules, mostly around doc comments
Several things done here:
- Set `max-issues-per-linter` to 0 so that we actually see all linter
warnings and not just 50 per linter. (As we also set
`max-same-issues` to 0, I assume this was the intention from the
beginning.)
- Stop using the golangci-lint default excludes (by setting
`exclude-use-default: false`. Those are too generous and don't match
our style conventions. (I have re-added some of the excludes
explicitly in this commit. See below.)
- Re-add the `errcheck` exclusion we have used so far via the
defaults.
- Exclude the signature requirement `govet` has for `Seek` methods
because we use non-standard `Seek` methods a lot. (But we keep other
requirements, while the default excludes completely disabled the
check for common method segnatures.)
- Exclude warnings about missing doc comments on exported symbols. (We
used to be pretty adamant about doc comments, but stopped that at
some point in the past. By now, we have about 500 missing doc
comments. We may consider reintroducing this check, but that's
outside of the scope of this commit. The default excludes of
golangci-lint essentially ignore doc comments completely.)
- By stop using the default excludes, we now get warnings back on
malformed doc comments. That's the most impactful change in this
commit. It does not enforce doc comments (again), but _if_ there is
a doc comment, it has to have the recommended form. (Most of the
changes in this commit are fixing this form.)
- Improve wording/spelling of some comments in .golangci.yml, and
remove an outdated comment.
- Leave `package-comments` inactive, but add a TODO asking if we
should change that.
- Add a new sub-linter `comment-spacings` (and fix corresponding
comments), which avoids missing spaces after the leading `//`.
Signed-off-by: beorn7 <beorn@grafana.com>
2024-08-22 11:59:36 +00:00
|
|
|
# So, it's needed to explicitly enable all required rules here.
|
2023-04-04 08:28:19 +00:00
|
|
|
rules:
|
2023-11-29 17:23:34 +00:00
|
|
|
# https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md
|
|
|
|
- name: blank-imports
|
lint: Revamp our linting rules, mostly around doc comments
Several things done here:
- Set `max-issues-per-linter` to 0 so that we actually see all linter
warnings and not just 50 per linter. (As we also set
`max-same-issues` to 0, I assume this was the intention from the
beginning.)
- Stop using the golangci-lint default excludes (by setting
`exclude-use-default: false`. Those are too generous and don't match
our style conventions. (I have re-added some of the excludes
explicitly in this commit. See below.)
- Re-add the `errcheck` exclusion we have used so far via the
defaults.
- Exclude the signature requirement `govet` has for `Seek` methods
because we use non-standard `Seek` methods a lot. (But we keep other
requirements, while the default excludes completely disabled the
check for common method segnatures.)
- Exclude warnings about missing doc comments on exported symbols. (We
used to be pretty adamant about doc comments, but stopped that at
some point in the past. By now, we have about 500 missing doc
comments. We may consider reintroducing this check, but that's
outside of the scope of this commit. The default excludes of
golangci-lint essentially ignore doc comments completely.)
- By stop using the default excludes, we now get warnings back on
malformed doc comments. That's the most impactful change in this
commit. It does not enforce doc comments (again), but _if_ there is
a doc comment, it has to have the recommended form. (Most of the
changes in this commit are fixing this form.)
- Improve wording/spelling of some comments in .golangci.yml, and
remove an outdated comment.
- Leave `package-comments` inactive, but add a TODO asking if we
should change that.
- Add a new sub-linter `comment-spacings` (and fix corresponding
comments), which avoids missing spaces after the leading `//`.
Signed-off-by: beorn7 <beorn@grafana.com>
2024-08-22 11:59:36 +00:00
|
|
|
- name: comment-spacings
|
2023-11-29 17:23:34 +00:00
|
|
|
- name: context-as-argument
|
|
|
|
arguments:
|
lint: Revamp our linting rules, mostly around doc comments
Several things done here:
- Set `max-issues-per-linter` to 0 so that we actually see all linter
warnings and not just 50 per linter. (As we also set
`max-same-issues` to 0, I assume this was the intention from the
beginning.)
- Stop using the golangci-lint default excludes (by setting
`exclude-use-default: false`. Those are too generous and don't match
our style conventions. (I have re-added some of the excludes
explicitly in this commit. See below.)
- Re-add the `errcheck` exclusion we have used so far via the
defaults.
- Exclude the signature requirement `govet` has for `Seek` methods
because we use non-standard `Seek` methods a lot. (But we keep other
requirements, while the default excludes completely disabled the
check for common method segnatures.)
- Exclude warnings about missing doc comments on exported symbols. (We
used to be pretty adamant about doc comments, but stopped that at
some point in the past. By now, we have about 500 missing doc
comments. We may consider reintroducing this check, but that's
outside of the scope of this commit. The default excludes of
golangci-lint essentially ignore doc comments completely.)
- By stop using the default excludes, we now get warnings back on
malformed doc comments. That's the most impactful change in this
commit. It does not enforce doc comments (again), but _if_ there is
a doc comment, it has to have the recommended form. (Most of the
changes in this commit are fixing this form.)
- Improve wording/spelling of some comments in .golangci.yml, and
remove an outdated comment.
- Leave `package-comments` inactive, but add a TODO asking if we
should change that.
- Add a new sub-linter `comment-spacings` (and fix corresponding
comments), which avoids missing spaces after the leading `//`.
Signed-off-by: beorn7 <beorn@grafana.com>
2024-08-22 11:59:36 +00:00
|
|
|
# Allow functions with test or bench signatures.
|
2023-11-29 17:23:34 +00:00
|
|
|
- allowTypesBefore: "*testing.T,testing.TB"
|
|
|
|
- name: context-keys-type
|
|
|
|
- name: dot-imports
|
|
|
|
# A lot of false positives: incorrectly identifies channel draining as "empty code block".
|
|
|
|
# See https://github.com/mgechev/revive/issues/386
|
|
|
|
- name: empty-block
|
|
|
|
disabled: true
|
|
|
|
- name: error-naming
|
|
|
|
- name: error-return
|
|
|
|
- name: error-strings
|
|
|
|
- name: errorf
|
|
|
|
- name: exported
|
|
|
|
- name: increment-decrement
|
|
|
|
- name: indent-error-flow
|
|
|
|
- name: package-comments
|
lint: Revamp our linting rules, mostly around doc comments
Several things done here:
- Set `max-issues-per-linter` to 0 so that we actually see all linter
warnings and not just 50 per linter. (As we also set
`max-same-issues` to 0, I assume this was the intention from the
beginning.)
- Stop using the golangci-lint default excludes (by setting
`exclude-use-default: false`. Those are too generous and don't match
our style conventions. (I have re-added some of the excludes
explicitly in this commit. See below.)
- Re-add the `errcheck` exclusion we have used so far via the
defaults.
- Exclude the signature requirement `govet` has for `Seek` methods
because we use non-standard `Seek` methods a lot. (But we keep other
requirements, while the default excludes completely disabled the
check for common method segnatures.)
- Exclude warnings about missing doc comments on exported symbols. (We
used to be pretty adamant about doc comments, but stopped that at
some point in the past. By now, we have about 500 missing doc
comments. We may consider reintroducing this check, but that's
outside of the scope of this commit. The default excludes of
golangci-lint essentially ignore doc comments completely.)
- By stop using the default excludes, we now get warnings back on
malformed doc comments. That's the most impactful change in this
commit. It does not enforce doc comments (again), but _if_ there is
a doc comment, it has to have the recommended form. (Most of the
changes in this commit are fixing this form.)
- Improve wording/spelling of some comments in .golangci.yml, and
remove an outdated comment.
- Leave `package-comments` inactive, but add a TODO asking if we
should change that.
- Add a new sub-linter `comment-spacings` (and fix corresponding
comments), which avoids missing spaces after the leading `//`.
Signed-off-by: beorn7 <beorn@grafana.com>
2024-08-22 11:59:36 +00:00
|
|
|
# TODO(beorn7): Currently, we have a lot of missing package doc comments. Maybe we should have them.
|
|
|
|
disabled: true
|
2023-11-29 17:23:34 +00:00
|
|
|
- name: range
|
|
|
|
- name: receiver-naming
|
|
|
|
- name: redefines-builtin-id
|
|
|
|
- name: superfluous-else
|
|
|
|
- name: time-naming
|
|
|
|
- name: unexported-return
|
|
|
|
- name: unreachable-code
|
2023-04-04 08:28:19 +00:00
|
|
|
- name: unused-parameter
|
|
|
|
disabled: true
|
2023-11-29 17:23:34 +00:00
|
|
|
- name: var-declaration
|
|
|
|
- name: var-naming
|
2023-12-07 11:35:01 +00:00
|
|
|
testifylint:
|
|
|
|
disable:
|
|
|
|
- float-compare
|
|
|
|
- go-require
|
2024-10-06 16:35:29 +00:00
|
|
|
enable-all: true
|