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 dc02378 commit b18f3a9
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 23 deletions.
26 changes: 13 additions & 13 deletions CHANGELOG.md
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
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 b18f3a9

Please sign in to comment.