dev: clean configuration, documentation, and code (#1911)

* Remove dead code related to golangci.com
* remove old build tags
* stale bot: remove bug label from `exemptLabels`
* order `gitignore` entries alphabetically
* doc: order `linters-settings` alphabetically
* remove obsolete exclude rule
* release: add docs prefix to skip the commit in the changelog
This commit is contained in:
Ludovic Fernandez 2021-04-14 12:48:48 +02:00 committed by GitHub
parent 93df6f75f5
commit 5d10450bc9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 116 additions and 88 deletions

3
.github/stale.yml vendored
View File

@ -8,7 +8,6 @@ daysUntilClose: 30
exemptLabels:
- pinned
- security
- bug
- blocked
- protected
- triaged
@ -23,4 +22,4 @@ markComment: >
for your contributions.
# Comment to post when closing a stale issue. Set to `false` to disable
closeComment: false
closeComment: false

View File

@ -38,6 +38,6 @@ jobs:
base: master
token: ${{ secrets.GOLANGCI_LINT_TOKEN }}
branch-suffix: timestamp
title: "Update documentation and assets"
title: "docs: Update documentation and assets"
team-reviewers: golangci/team
delete-branch: true

16
.gitignore vendored
View File

@ -1,19 +1,19 @@
/*.txt
*.test
.DS_Store
/*.pdf
/*.pprof
/dist/
/tools/dist/
/*.txt
/.idea/
/test/path
/.vscode/
/dist/
/golangci-lint
/test/path
/tools/Dracula.itermcolors
/tools/dist/
/tools/godownloader
/tools/goreleaser
/tools/node_modules
/tools/svg-term
/vendor/
/.vscode/
*.test
.DS_Store
coverage.out
coverage.xml
coverage.xml

View File

@ -82,12 +82,23 @@ output:
# all available settings of specific linters
linters-settings:
cyclop:
# the maximal code complexity to report
max-complexity: 10
# the maximal average package complexity. If it's higher than 0.0 (float) the check is enabled (default 0.0)
package-average: 0.0
# should ignore tests (default false)
skip-tests: false
dogsled:
# checks assignments with too many blank identifiers; default is 2
max-blank-identifiers: 2
dupl:
# tokens count to trigger issue, 150 by default
threshold: 100
errcheck:
# report about not checking of errors in type assertions: `a := b.(MyStruct)`;
# default is false: such cases aren't reported by default.
@ -105,6 +116,11 @@ linters-settings:
# path to a file containing a list of functions to exclude from checking
# see https://github.com/kisielk/errcheck#excluding-functions for details
exclude: /path/to/file.txt
errorlint:
# Report non-wrapping error creation using fmt.Errorf
errorf: true
exhaustive:
# check switch statements in generated files also
check-generated: false
@ -112,31 +128,47 @@ linters-settings:
# 'default' case is present, even if all enum members aren't listed in the
# switch
default-signifies-exhaustive: false
exhaustivestruct:
struct-patterns:
- '*.Test'
- '*.Test2'
- '*.Embedded'
- '*.External'
forbidigo:
# Forbid the following identifiers
forbid:
- fmt.Errorf # consider errors.Errorf in github.com/pkg/errors
- fmt.Print.* # too much log noise
- ginkgo\\.F.* # these are used just for local development
# Exclude godoc examples from forbidigo checks. Default is true.
exclude_godoc_examples: false
funlen:
lines: 60
statements: 40
gci:
# put imports beginning with prefix after 3rd-party packages;
# only support one prefix
# if not set, use goimports.local-prefixes
local-prefixes: github.com/org/project
gocognit:
# minimal code complexity to report, 30 by default (but we recommend 10-20)
min-complexity: 10
nestif:
# minimal complexity of if statements to report, 5 by default
min-complexity: 4
goconst:
# minimal length of string constant, 3 by default
min-len: 3
# minimal occurrences count to trigger, 3 by default
min-occurrences: 3
gocritic:
# Which checks should be enabled; can't be combined with 'disabled-checks';
# See https://go-critic.github.io/overview#checks-overview
@ -194,17 +226,11 @@ linters-settings:
unnamedResult:
# whether to check exported functions
checkExported: true
gocyclo:
# minimal code complexity to report, 30 by default (but we recommend 10-20)
min-complexity: 10
cyclop:
# the maximal code complexity to report
max-complexity: 10
# the maximal average package complexity. If it's higher than 0.0 (float) the check is enabled (default 0.0)
package-average: 0.0
# should ignore tests (default false)
skip-tests: false
godot:
# comments to be checked: `declarations`, `toplevel`, or `all`
scope: declarations
@ -214,6 +240,7 @@ linters-settings:
# - '[0-9]+'
# check that each sentence starts with a capital letter
capital: false
godox:
# report any comments starting with keywords, this is useful for TODO or FIXME comments that
# might be left in the code accidentally and should be resolved before merging
@ -221,9 +248,16 @@ linters-settings:
- NOTE
- OPTIMIZE # marks code that should be optimized before merging
- HACK # marks hack-arounds that should be removed before merging
gofmt:
# simplify code: gofmt with `-s` option, true by default
simplify: true
gofumpt:
# Choose whether or not to use the extra rules that are disabled
# by default
extra-rules: false
goheader:
values:
const:
@ -252,13 +286,16 @@ linters-settings:
# limitations under the License.
template-path:
# also as alternative of directive 'template' you may put the path to file with the template source
goimports:
# put imports beginning with prefix after 3rd-party packages;
# it's a comma-separated list of prefixes
local-prefixes: github.com/org/project
golint:
# minimal confidence for issues, default is 0.8
min-confidence: 0.8
gomnd:
settings:
mnd:
@ -267,6 +304,18 @@ linters-settings:
# ignored-numbers: 1000
# ignored-files: magic_.*.go
# ignored-functions: math.*
gomoddirectives:
# Allow local `replace` directives. Default is false.
replace-local: false
# List of allowed `replace` directives. Default is empty.
replace-allow-list:
- launchpad.net/gocheck
# Allow to not explain why the version has been retracted in the `retract` directives. Default is false.
retract-allow-no-explanation: false
# Forbid the use of the `exclude` directives. Default is false.
exclude-forbidden: false
gomodguard:
allowed:
modules: # List of allowed modules
@ -284,6 +333,7 @@ linters-settings:
# version: "< 1.1.0" # Version constraint, see https://github.com/Masterminds/semver#basic-comparisons
# reason: "testing if blocked version constraint works." # Reason why the version constraint exists. (Optional)
local_replace_directives: false # Set to true to raise lint issues for packages that are loaded from a local path via replace directive
govet:
# report about shadowed variables
check-shadowing: true
@ -305,6 +355,7 @@ linters-settings:
disable:
- shadow
disable-all: false
depguard:
list-type: blacklist
include-go-root: false
@ -313,21 +364,39 @@ linters-settings:
packages-with-error-message:
# specify an error message to output when a blacklisted package is used
- github.com/sirupsen/logrus: "logging is allowed only by logutils.Log"
ifshort:
# Maximum length of variable declaration measured in number of lines, after which linter won't suggest using short syntax.
# Has higher priority than max-decl-chars.
max-decl-lines: 1
# Maximum length of variable declaration measured in number of characters, after which linter won't suggest using short syntax.
max-decl-chars: 30
importas:
# using `servingv1` alias for `knative.dev/serving/pkg/apis/serving/v1` package
servingv1: knative.dev/serving/pkg/apis/serving/v1
# using `autoscalingv1alpha1` alias for `knative.dev/serving/pkg/apis/autoscaling/v1alpha1` package
autoscalingv1alpha1: knative.dev/serving/pkg/apis/autoscaling/v1alpha1
# You can specify the package path by regular expression,
# and alias by regular expression expansion syntax like below.
# see https://github.com/julz/importas#use-regular-expression for details
"$1$2": 'knative.dev/serving/pkg/apis/(\w+)/(v[\w\d]+)'
lll:
# max line length, lines longer will be reported. Default is 120.
# '\t' is counted as 1 character by default, and can be changed with the tab-width option
line-length: 120
# tab width in spaces. Default to 1.
tab-width: 1
makezero:
# Allow only slices initialized with a length of zero. Default is false.
always: false
maligned:
# print struct with more effective memory layout or not, false by default
suggest-new: true
misspell:
# Correct spellings using locale preferences for US or UK.
# Default is to use a neutral variety of English.
@ -335,9 +404,11 @@ linters-settings:
locale: US
ignore-words:
- someword
nakedret:
# make an issue if func has more lines of code than this setting and it has naked returns; default is 30
max-func-lines: 30
prealloc:
# XXX: we don't recommend using this linter before doing performance profiling.
# For most programs usage of prealloc will be a premature optimization.
@ -347,6 +418,7 @@ linters-settings:
simple: true
range-loops: true # Report preallocation suggestions on range loops, true by default
for-loops: false # Report preallocation suggestions on for loops, false by default
promlinter:
# Promlinter cannot infer all metrics name in static analysis.
# Enable strict mode will also include the errors caused by failing to parse the args.
@ -361,11 +433,13 @@ linters-settings:
# - "ReservedChars"
# - "CamelCase"
# - "lintUnitAbbreviations"
predeclared:
# comma-separated list of predeclared identifiers to not report on
ignore: ""
# include method names and field names (i.e., qualified names) in checks
q: false
nolintlint:
# Enable to ensure that nolint directives are all used. Default is true.
allow-unused: false
@ -377,9 +451,11 @@ linters-settings:
require-explanation: true
# Enable to require nolint directives to mention the specific linter being suppressed. Default is false.
require-specific: true
rowserrcheck:
packages:
- github.com/jmoiron/sqlx
-
revive:
# see https://github.com/mgechev/revive#available-rules for details.
ignore-generated-header: true
@ -387,9 +463,26 @@ linters-settings:
rules:
- name: indent-error-flow
severity: warning
tagliatelle:
# check the struck tag name case
case:
# use the struct field name to check the name of the struct tag
use-field-name: true
rules:
# any struct tag type can be used.
# support string case: `camel`, `pascal`, `kebab`, `snake`, `goCamel`, `goPascal`, `goKebab`, `goSnake`, `upper`, `lower`
json: camel
yaml: camel
xml: camel
bson: camel
avro: snake
mapstructure: kebab
testpackage:
# regexp pattern to skip files
skip-regexp: (export|internal)_test\.go
thelper:
# The following configurations enable all checks. It can be omitted because all checks are enabled by default.
# You can enable only required checks deleting unnecessary checks.
@ -405,21 +498,25 @@ linters-settings:
first: true
name: true
begin: true
unparam:
# Inspect exported functions, default is false. Set to true if no external program/library imports your code.
# XXX: if you enable this setting, unparam will report a lot of false-positives in text editors:
# if it's called for subdir of a project it can't find external interfaces. All text editor integrations
# with golangci-lint call it on a directory with the changed file.
check-exported: false
unused:
# treat code as a program (not a library) and report unused exported identifiers; default is false.
# XXX: if you enable this setting, unused will report a lot of false-positives in text editors:
# if it's called for subdir of a project it can't find funcs usages. All text editor integrations
# with golangci-lint call it on a directory with the changed file.
check-exported: false
whitespace:
multi-if: false # Enforces newlines (or comments) after every multi-line if statement
multi-func: false # Enforces newlines (or comments) after every multi-line function signature
wsl:
# If true append is only allowed to be cuddled if appending value is
# matching variables, fields or types on line above. Default is true.
@ -441,57 +538,6 @@ linters-settings:
force-err-cuddling: false
# Allow leading comments to be separated with empty lines
allow-separated-leading-comment: false
gofumpt:
# Choose whether or not to use the extra rules that are disabled
# by default
extra-rules: false
errorlint:
# Report non-wrapping error creation using fmt.Errorf
errorf: true
makezero:
# Allow only slices initialized with a length of zero. Default is false.
always: false
forbidigo:
# Forbid the following identifiers
forbid:
- fmt.Errorf # consider errors.Errorf in github.com/pkg/errors
- fmt.Print.* # too much log noise
- ginkgo\\.F.* # these are used just for local development
# Exclude godoc examples from forbidigo checks. Default is true.
exclude_godoc_examples: false
importas:
# using `servingv1` alias for `knative.dev/serving/pkg/apis/serving/v1` package
servingv1: knative.dev/serving/pkg/apis/serving/v1
# using `autoscalingv1alpha1` alias for `knative.dev/serving/pkg/apis/autoscaling/v1alpha1` package
autoscalingv1alpha1: knative.dev/serving/pkg/apis/autoscaling/v1alpha1
# You can specify the package path by regular expression,
# and alias by regular expression expansion syntax like below.
# see https://github.com/julz/importas#use-regular-expression for details
"$1$2": 'knative.dev/serving/pkg/apis/(\w+)/(v[\w\d]+)'
gomoddirectives:
# Allow local `replace` directives. Default is false.
replace-local: false
# List of allowed `replace` directives. Default is empty.
replace-allow-list:
- launchpad.net/gocheck
# Allow to not explain why the version has been retracted in the `retract` directives. Default is false.
retract-allow-no-explanation: false
# Forbid the use of the `exclude` directives. Default is false.
exclude-forbidden: false
tagliatelle:
# check the struck tag name case
case:
# use the struct field name to check the name of the struct tag
use-field-name: true
rules:
# any struct tag type can be used.
# support string case: `camel`, `pascal`, `kebab`, `snake`, `goCamel`, `goPascal`, `goKebab`, `goSnake`, `upper`, `lower`
json: camel
yaml: camel
xml: camel
bson: camel
avro: snake
mapstructure: kebab
# The custom section can be used to define linter plugins to be loaded at runtime. See README doc
# for more info.

View File

@ -128,11 +128,6 @@ issues:
linters:
- gomnd
# https://github.com/go-critic/go-critic/issues/926
- linters:
- gocritic
text: "unnecessaryDefer:"
run:
skip-dirs:
- test/testdata_etc

View File

@ -1,5 +1,3 @@
// +build go1.12
package main
import (

View File

@ -2,7 +2,6 @@ package lintersdb
import (
"fmt"
"os"
"path/filepath"
"plugin"
@ -497,7 +496,6 @@ func (m Manager) GetAllSupportedLinterConfigs() []*linter.Config {
WithURL("https://github.com/golangci/golangci-lint/blob/master/pkg/golinters/nolintlint/README.md"),
}
isLocalRun := os.Getenv("GOLANGCI_COM_RUN") == ""
enabledByDefault := map[string]bool{
golinters.NewGovet(nil).Name(): true,
golinters.NewErrcheck().Name(): true,
@ -508,9 +506,7 @@ func (m Manager) GetAllSupportedLinterConfigs() []*linter.Config {
golinters.NewVarcheck().Name(): true,
golinters.NewIneffassign().Name(): true,
golinters.NewDeadcode().Name(): true,
// don't typecheck for golangci.com: too many troubles
golinters.NewTypecheck().Name(): isLocalRun,
golinters.NewTypecheck().Name(): true,
}
return enableLinterConfigs(lcs, func(lc *linter.Config) bool {
return enabledByDefault[lc.Name()]

View File

@ -3,7 +3,6 @@ package lint
import (
"context"
"fmt"
"os"
"runtime/debug"
"strings"
@ -194,24 +193,19 @@ func (r Runner) Run(ctx context.Context, linters []*linter.Config, lintCtx *lint
defer sw.Print()
var issues []result.Issue
var runErr error
for _, lc := range linters {
lc := lc
sw.TrackStage(lc.Name(), func() {
linterIssues, err := r.runLinterSafe(ctx, lintCtx, lc)
if err != nil {
r.Log.Warnf("Can't run linter %s: %v", lc.Linter.Name(), err)
if os.Getenv("GOLANGCI_COM_RUN") == "" {
// Don't stop all linters on one linter failure for golangci.com.
runErr = err
}
return
}
issues = append(issues, linterIssues...)
})
}
return r.processLintResults(issues), runErr
return r.processLintResults(issues), nil
}
func (r *Runner) processIssues(issues []result.Issue, sw *timeutils.Stopwatch, statPerProcessor map[string]processorStat) []result.Issue {