Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 13 additions & 13 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,27 +16,27 @@ There is the most valuable changes log:
* `asasalint`: https://github.com/alingse/asasalint
* `nosnakecase`: https://github.com/sivchari/nosnakecase
2. updated linters:
* `decorder`: from 0.2.1 to 0.2.2
* `errcheck`: from 1.6.0 to 1.6.1
* `errname`: from 0.1.6 to 0.1.7
* `exhaustive`: from 0.7.11 to 0.8.1
* `gci`: fix issues and re-enable autofix
* `gci`: from 0.3.4 to 0.4.2
* `nonamedreturns`: from 1.0.1 to 1.0.4
* `gocyclo`: from 0.5.1 to 0.6.0
* `go-exhaustruct`: from 2.1.0 to 2.2.0
* `errcheck`: from 1.6.0 to 1.6.1
* `thelper`: from 0.6.2 to 0.6.3
* `paralleltest`: from 1.0.3 to 1.0.6
* `testpackage`: from 1.0.1 to 1.1.0
* `exhaustive`: from 0.7.11 to 0.8.1
* `go-ruleguard`: from 0.3.19 to 0.3.21
* `gosec`: from 2.11.0 to 2.12.0
* `tenv`: from 1.5.0 to 1.6.0
* `wrapcheck`: from 2.6.1 to 2.6.2
* `gocognit`: from 1.0.5 to 1.0.6
* `decorder`: from 0.2.1 to 0.2.2
* `honnef.co/go/tools`: from 0.3.1 to 0.3.2
* `gocyclo`: from 0.5.1 to 0.6.0
* `golang.org/x/tools`: bump to HEAD
* `gci`: fix issues and re-enable autofix
* `gosec`: allow `global` config
* `gosec`: from 2.11.0 to 2.12.0
* `nonamedreturns`: from 1.0.1 to 1.0.4
* `paralleltest`: from 1.0.3 to 1.0.6
* `staticcheck`: fix generics
* `staticcheck`: from 0.3.1 to 0.3.2
* `tenv`: from 1.5.0 to 1.6.0
* `testpackage`: from 1.0.1 to 1.1.0
* `thelper`: from 0.6.2 to 0.6.3
* `wrapcheck`: from 2.6.1 to 2.6.2
3. documentation:
* add thanks page
* add a clear explanation about the `staticcheck` integration.
Expand Down
52 changes: 42 additions & 10 deletions pkg/golinters/revive.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (
"go/token"
"os"
"reflect"
"strings"
"sync"

"github.com/BurntSushi/toml"
Expand Down Expand Up @@ -186,6 +187,7 @@ func getReviveConfig(cfg *config.ReviveSettings) (*lint.Config, error) {
}

normalizeConfig(conf)
ignoreRules(conf)

reviveDebugf("revive configuration: %#v", conf)

Expand Down Expand Up @@ -254,23 +256,23 @@ func safeTomlSlice(r []interface{}) []interface{} {
// This element is not exported by revive, so we need copy the code.
// Extracted from https://github.com/mgechev/revive/blob/v1.1.4/config/config.go#L15
var defaultRules = []lint.Rule{
&rule.VarDeclarationsRule{},
// &rule.VarDeclarationsRule{}, // TODO(ldez) https://github.com/golangci/golangci-lint/issues/2997 (var-declaration)
&rule.PackageCommentsRule{},
&rule.DotImportsRule{},
&rule.BlankImportsRule{},
&rule.ExportedRule{},
&rule.VarNamingRule{},
&rule.IndentErrorFlowRule{},
&rule.RangeRule{},
&rule.ErrorfRule{},
// &rule.ErrorfRule{}, // TODO(ldez) https://github.com/golangci/golangci-lint/issues/2997 (errorf
&rule.ErrorNamingRule{},
&rule.ErrorStringsRule{},
&rule.ReceiverNamingRule{},
&rule.IncrementDecrementRule{},
&rule.ErrorReturnRule{},
&rule.UnexportedReturnRule{},
&rule.TimeNamingRule{},
&rule.ContextKeysType{},
// &rule.UnexportedReturnRule{}, // TODO(ldez) https://github.com/golangci/golangci-lint/issues/2997 (unexported-return)
// &rule.TimeNamingRule{}, // TODO(ldez) https://github.com/golangci/golangci-lint/issues/2997 (time-naming)
// &rule.ContextKeysType{}, // TODO(ldez) https://github.com/golangci/golangci-lint/issues/2997 (context-keys-type)
&rule.ContextAsArgumentRule{},
}

Expand All @@ -291,15 +293,15 @@ var allRules = append([]lint.Rule{
&rule.FlagParamRule{},
&rule.UnnecessaryStmtRule{},
&rule.StructTagRule{},
&rule.ModifiesValRecRule{},
// &rule.ModifiesValRecRule{}, // TODO(ldez) https://github.com/golangci/golangci-lint/issues/2997 (modifies-value-receiver)
&rule.ConstantLogicalExprRule{},
&rule.BoolLiteralRule{},
&rule.RedefinesBuiltinIDRule{},
&rule.ImportsBlacklistRule{},
&rule.FunctionResultsLimitRule{},
&rule.MaxPublicStructsRule{},
&rule.RangeValInClosureRule{},
&rule.RangeValAddress{},
// &rule.RangeValAddress{}, // TODO(ldez) https://github.com/golangci/golangci-lint/issues/2997 (range-val-address)
&rule.WaitGroupByValueRule{},
&rule.AtomicRule{},
&rule.EmptyLinesRule{},
Expand All @@ -309,9 +311,9 @@ var allRules = append([]lint.Rule{
&rule.ImportShadowingRule{},
&rule.BareReturnRule{},
&rule.UnusedReceiverRule{},
&rule.UnhandledErrorRule{},
// &rule.UnhandledErrorRule{}, // TODO(ldez) https://github.com/golangci/golangci-lint/issues/2997 (unhandled-error)
&rule.CognitiveComplexityRule{},
&rule.StringOfIntRule{},
// &rule.StringOfIntRule{}, // TODO(ldez) https://github.com/golangci/golangci-lint/issues/2997 (string-of-int)
&rule.StringFormatRule{},
&rule.EarlyReturnRule{},
&rule.UnconditionalRecursionRule{},
Expand All @@ -322,7 +324,7 @@ var allRules = append([]lint.Rule{
&rule.NestedStructs{},
&rule.IfReturnRule{},
&rule.UselessBreak{},
&rule.TimeEqualRule{},
// &rule.TimeEqualRule{}, // TODO(ldez) https://github.com/golangci/golangci-lint/issues/2997 (time-equal)
&rule.BannedCharsRule{},
&rule.OptimizeOperandsOrderRule{},
}, defaultRules...)
Expand Down Expand Up @@ -388,3 +390,33 @@ func defaultConfig() *lint.Config {
}
return &defaultConfig
}

// TODO(ldez) https://github.com/golangci/golangci-lint/issues/2997
func ignoreRules(conf *lint.Config) {
f := []string{
"context-keys-type",
"errorf",
"modifies-value-receiver",
"range-val-address",
"string-of-int",
"time-equal",
"time-naming",
"unexported-return",
"unhandled-error",
"var-declaration",
}

var ignored []string
for _, s := range f {
if _, ok := conf.Rules[s]; ok {
delete(conf.Rules, s)
ignored = append(ignored, s)
}
}

if len(ignored) > 0 {
linterLogger.Warnf("revive: the following rules (%s) are ignored due to a performance problem "+
"(https://github.com/golangci/golangci-lint/issues/2997)",
strings.Join(ignored, ","))
}
}