This repository was archived by the owner on Jul 28, 2026. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 513
Extend linting configuration file #1421
Merged
rfratto
merged 6 commits into
grafana-cold-storage:main
from
rfratto:lint-github-pkg-errors
Feb 24, 2022
Merged
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
6b9333c
add depguard linter to reject packages we tend to avoid
rfratto d265322
temporarily add in rejected package to make sure CI rejects
rfratto bb43d83
update golangci-lint to v1.44 to use denylist over blacklist
rfratto d18d0c3
Revert "temporarily add in rejected package to make sure CI rejects"
rfratto 9a78100
add golang.org/x/sync/errgroup to package denylist
rfratto 0982701
refactor golangci.yml
rfratto File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,74 +1,83 @@ | ||
| # This file contains all available configuration options | ||
| # with their default values. | ||
| # Full list of configuration options: https://golangci-lint.run/usage/configuration/ | ||
|
|
||
| # options for analysis running | ||
| run: | ||
| # default concurrency is a available CPU number | ||
| concurrency: 16 | ||
|
|
||
| # timeout for analysis, e.g. 30s, 5m, default is 1m | ||
| timeout: 5m | ||
|
|
||
| # exit code when at least one issue was found, default is 1 | ||
| issues-exit-code: 1 | ||
|
|
||
| # include test files or not, default is true | ||
| tests: true | ||
|
|
||
| # list of build2 tags, all linters use it. Default is empty list. | ||
| build-tags: | ||
|
|
||
| # which dirs to skip: they won't be analyzed; | ||
| # can use regexp here: generated.*, regexp is applied on full path; | ||
| # default value is empty list, but next dirs are always skipped independently | ||
| # from this option's value: | ||
| # vendor$, third_party$, testdata$, examples$, Godeps$, builtin$ | ||
| skip-dirs: | ||
| # which files to skip: they will be analyzed, but issues from them | ||
| # won't be reported. Default value is empty list, but there is | ||
| # no need to include all autogenerated files, we confidently recognize | ||
| # autogenerated files. If it's not please let us know. | ||
| skip-files: | ||
| # output configuration options | ||
| output: | ||
| # colored-line-number|line-number|json|tab|checkstyle, default is "colored-line-number" | ||
| format: colored-line-number | ||
|
|
||
| # print lines of code with issue, default is true | ||
| print-issued-lines: true | ||
|
|
||
| # print linter name in the end of issue text, default is true | ||
| print-linter-name: true | ||
| sort-results: true | ||
|
|
||
| linters: | ||
| enable: | ||
| - deadcode | ||
| - errcheck | ||
| - goconst | ||
| - gofmt | ||
| - goimports | ||
| - golint | ||
| - gosimple | ||
| - ineffassign | ||
| - megacheck | ||
| - misspell | ||
| - structcheck | ||
| - unconvert | ||
| - unparam | ||
| - varcheck | ||
| - govet | ||
| - unused # new from here. | ||
| - interfacer | ||
| - typecheck | ||
| - deadcode # Report on unused code | ||
| - errcheck # Report unchecked errors | ||
| - goconst # Find repeated strings that could be replaced by constant | ||
| - gofmt # Check whether code was gofmt-ed | ||
| - goimports # Check imports were formatted with gofmt | ||
| - revive # Broad set of rules; replaces deprecated golint | ||
| - gosimple # Check whether code can be simplified | ||
| - ineffassign # Detect when assignment to variable is never used | ||
| - misspell # Report on commonly misspelled English words | ||
| - structcheck # Report on unused struct fields | ||
| - unconvert # Remove unnecessary type conversions | ||
| - unparam # Detect unused function parameters | ||
| - varcheck # Find unused global variables/constants | ||
| - govet # `go vet` | ||
| - unused # Detect unused constants/variables/functions/types | ||
| - typecheck # Ensure code typechecks | ||
| - depguard # Allow/denylist specific imports | ||
| - makezero # Detect misuse of make with non-zero length and append | ||
| - tenv # Use testing.(*T).Setenv instead of os.Setenv | ||
| - whitespace # Report unnecessary blank lines | ||
|
|
||
| issues: | ||
| # golangci-lint excludes some stuff we want by default (i.e., proper go-style comments). | ||
| # We exclude the defaults and then manually exclude the subset of defaults we truly don't | ||
| # care about. | ||
| # We want to use our own exclusion rules and ignore all the defaults. | ||
| exclude-use-default: false | ||
|
|
||
| exclude-rules: | ||
| # It's fine if tests ignore errors. | ||
| - path: _test.go | ||
| linters: | ||
| - errcheck | ||
|
|
||
| exclude: | ||
| # EXC0001 errcheck: Almost all programs ignore errors on these functions | ||
| # and in most cases it's ok. This is copied from the golangci-lint defaults | ||
| # mut modified to include go-kit logging. | ||
| - Error return value of .((os\.)?std(out|err)\..*|.*Close|.*Flush|os\.Remove(All)?|.*print(f|ln)?|os\.(Un)?Setenv|.*\.Log). is not checked | ||
| # Ignoring errors on Close, Log, and removing files is OK in most cases. | ||
| - "Error return value of `(.*\\.Close|.*\\.Log|os.Remove)` is not checked" | ||
| # Packages for integrations are named matching their upstream counterpart, | ||
| # which almost always have underscores. | ||
| - "var-naming: don't use an underscore in package name" | ||
|
|
||
| # Linter settings options: https://golangci-lint.run/usage/linters/ | ||
| linters-settings: | ||
| depguard: | ||
| # We want to report errors on stdlib packages, not just third party modules | ||
| include-go-root: true | ||
|
|
||
| packages-with-error-message: | ||
| - sync/atomic: "Use go.uber.org/atomic instead of sync/atomic" | ||
| - github.com/pkg/errors: "Use errors instead of github.com/pkg/errors" | ||
| - github.com/go-kit/kit/log: "Use github.com/go-kit/log instead of github.com/go-kit/kit/log" | ||
| - golang.org/x/sync/errgroup: "Use github.com/oklog/run instead of golang.org/x/sync/errgroup" | ||
|
|
||
| whitespace: | ||
| # While there normally shouldn't be extra redundant leading/trailing | ||
| # whitespace, if statement conditions and function headers that cross | ||
| # multiple lines are an exception. | ||
| # | ||
| # if true || | ||
| # false { | ||
| # | ||
| # // ... ^ must have empty line above | ||
| # } | ||
| # | ||
| # func foo( | ||
| # a int, | ||
| # ) { | ||
| # | ||
| # // ... ^ must have empty line above | ||
| # } | ||
| # | ||
| # This helps readers easily separate where the multi-line if/function ends | ||
| # at a glance. | ||
| multi-if: true | ||
| multi-func: true | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.