Skip to content

Commit

Permalink
revive: ignore slow rules
Browse files Browse the repository at this point in the history
  • Loading branch information
ldez committed Jul 20, 2022
1 parent aa0a219 commit 79bac57
Showing 1 changed file with 31 additions and 10 deletions.
41 changes: 31 additions & 10 deletions pkg/golinters/revive.go
Expand Up @@ -186,6 +186,7 @@ func getReviveConfig(cfg *config.ReviveSettings) (*lint.Config, error) {
}

normalizeConfig(conf)
ignoreRules(conf)

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

Expand Down Expand Up @@ -254,23 +255,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 +292,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 +310,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 +323,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 +389,23 @@ 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",
}

for _, s := range f {
delete(conf.Rules, s)
}
}

0 comments on commit 79bac57

Please sign in to comment.