Skip to content

Commit

Permalink
fix: restore rules
Browse files Browse the repository at this point in the history
  • Loading branch information
ldez committed Aug 7, 2022
1 parent 37dbfc6 commit 247dd54
Showing 1 changed file with 10 additions and 42 deletions.
52 changes: 10 additions & 42 deletions pkg/golinters/revive.go
Expand Up @@ -7,7 +7,6 @@ import (
"go/token"
"os"
"reflect"
"strings"
"sync"

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

normalizeConfig(conf)
ignoreRules(conf)

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

Expand Down Expand Up @@ -252,23 +250,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{}, // TODO(ldez) https://github.com/golangci/golangci-lint/issues/2997 (var-declaration)
&rule.VarDeclarationsRule{},
&rule.PackageCommentsRule{},
&rule.DotImportsRule{},
&rule.BlankImportsRule{},
&rule.ExportedRule{},
&rule.VarNamingRule{},
&rule.IndentErrorFlowRule{},
&rule.RangeRule{},
// &rule.ErrorfRule{}, // TODO(ldez) https://github.com/golangci/golangci-lint/issues/2997 (errorf
&rule.ErrorfRule{},
&rule.ErrorNamingRule{},
&rule.ErrorStringsRule{},
&rule.ReceiverNamingRule{},
&rule.IncrementDecrementRule{},
&rule.ErrorReturnRule{},
// &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.UnexportedReturnRule{},
&rule.TimeNamingRule{},
&rule.ContextKeysType{},
&rule.ContextAsArgumentRule{},
}

Expand All @@ -289,15 +287,15 @@ var allRules = append([]lint.Rule{
&rule.FlagParamRule{},
&rule.UnnecessaryStmtRule{},
&rule.StructTagRule{},
// &rule.ModifiesValRecRule{}, // TODO(ldez) https://github.com/golangci/golangci-lint/issues/2997 (modifies-value-receiver)
&rule.ModifiesValRecRule{},
&rule.ConstantLogicalExprRule{},
&rule.BoolLiteralRule{},
&rule.RedefinesBuiltinIDRule{},
&rule.ImportsBlacklistRule{},
&rule.FunctionResultsLimitRule{},
&rule.MaxPublicStructsRule{},
&rule.RangeValInClosureRule{},
// &rule.RangeValAddress{}, // TODO(ldez) https://github.com/golangci/golangci-lint/issues/2997 (range-val-address)
&rule.RangeValAddress{},
&rule.WaitGroupByValueRule{},
&rule.AtomicRule{},
&rule.EmptyLinesRule{},
Expand All @@ -307,9 +305,9 @@ var allRules = append([]lint.Rule{
&rule.ImportShadowingRule{},
&rule.BareReturnRule{},
&rule.UnusedReceiverRule{},
// &rule.UnhandledErrorRule{}, // TODO(ldez) https://github.com/golangci/golangci-lint/issues/2997 (unhandled-error)
&rule.UnhandledErrorRule{},
&rule.CognitiveComplexityRule{},
// &rule.StringOfIntRule{}, // TODO(ldez) https://github.com/golangci/golangci-lint/issues/2997 (string-of-int)
&rule.StringOfIntRule{},
&rule.StringFormatRule{},
&rule.EarlyReturnRule{},
&rule.UnconditionalRecursionRule{},
Expand All @@ -320,7 +318,7 @@ var allRules = append([]lint.Rule{
&rule.NestedStructs{},
&rule.IfReturnRule{},
&rule.UselessBreak{},
// &rule.TimeEqualRule{}, // TODO(ldez) https://github.com/golangci/golangci-lint/issues/2997 (time-equal)
&rule.TimeEqualRule{},
&rule.BannedCharsRule{},
&rule.OptimizeOperandsOrderRule{},
}, defaultRules...)
Expand Down Expand Up @@ -386,33 +384,3 @@ 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, ","))
}
}

0 comments on commit 247dd54

Please sign in to comment.