Skip to content

Instantly share code, notes, and snippets.

@akrisanov
Created May 2, 2022 17:58
Show Gist options
  • Save akrisanov/e65f2d4f493cffff6019e99dfc67c104 to your computer and use it in GitHub Desktop.
Save akrisanov/e65f2d4f493cffff6019e99dfc67c104 to your computer and use it in GitHub Desktop.
# See explanation of linters at https://golangci-lint.run/usage/linters/
linters:
disable-all: true
enable:
- bodyclose
# Disabled due to flakes: https://github.com/sourcegraph/sourcegraph/issues/33183
# - depguard
- forbidigo
- gocritic
- goimports
- gosimple
- govet
- ineffassign
# this is flakey: https://github.com/sourcegraph/sourcegraph/issues/34304
# - nolintlint
- staticcheck
- typecheck
- unconvert
- unused
- unparam
- exportloopref
linters-settings:
depguard:
list-type: denylist
include-go-root: true
packages-with-error-message:
# Deprecated packages
- io/ioutil: "The ioutil package has been deprecated"
# Blacklisted error packages
- errors: "Use github.com/sourcegraph/sourcegraph/lib/errors instead"
- github.com/pkg/errors: "Use github.com/sourcegraph/sourcegraph/lib/errors instead"
- github.com/cockroachdb/errors: "Use github.com/sourcegraph/sourcegraph/lib/errors instead"
- github.com/hashicorp/go-multierror: "Use github.com/sourcegraph/sourcegraph/lib/errors instead"
# More performant regexp
- regexp: "Use github.com/grafana/regexp instead"
gocritic:
disabled-checks:
- appendAssign # Too many false positives
- assignOp # Maybe worth adding, but likely not worth the noise
- commentFormatting # No strong benefit
- deprecatedComment # Unnecessary
- exitAfterDefer # Only occurs in auxiliary tools
- ifElseChain # Noisy for not much gain
- singleCaseSwitch # Noisy for not much gain
govet:
disable:
- composites
forbidigo:
forbid:
# Use errors.Newf instead
- '^fmt\.Errorf$'
issues:
exclude-rules:
# Exclude bodyclose lint from tests because leaking connections in tests
# is a non-issue, and checking that adds unnecessary noise
- path: _test\.go
linters:
- bodyclose
run:
timeout: 5m
skip-dirs:
- client
- ui
- vendor
- node_modules
- docker-images/syntax-highlighter
skip-files:
# Auto-generated with depguard and forbidigo failures
- schema/schema.go
# Imports blacklisted errors
# Unfortunately golangci-lint doesn't really like multiple go.mod files, so
# whenever we reference a file here it's relative to its containing workspace.
# These values are under the ./lib module.
- errors/cockroach.go
# These are all projects with distinct go.mod files that can't import lib
# due to not knowing an absolute path to the user's sourcegraph directory
# and go mod replace directives not accepting relative paths.
#
# We should remove the go.mod files in these directories and share the set
# of dependencies in the root module (which has access to the colocated lib)
# like we did with sg. That seemed very successful!
# In ./enterprise/dev/insight-data-gen
- main.go
# In ./internal/cmd/progress-bot
- main.go
# In ./internal/cmd/resources-report
- aws.go
- gcp.go
- main.go
- resource.go
- sheets.go
- slack.go
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment