Skip to content

Commit 61673b3

Browse files
authored
revive: ignore slow rules (#2999)
1 parent 3fb60a3 commit 61673b3

File tree

2 files changed

+55
-23
lines changed

2 files changed

+55
-23
lines changed

CHANGELOG.md

+13-13
Original file line numberDiff line numberDiff line change
@@ -16,27 +16,27 @@ There is the most valuable changes log:
1616
* `asasalint`: https://github.com/alingse/asasalint
1717
* `nosnakecase`: https://github.com/sivchari/nosnakecase
1818
2. updated linters:
19+
* `decorder`: from 0.2.1 to 0.2.2
20+
* `errcheck`: from 1.6.0 to 1.6.1
1921
* `errname`: from 0.1.6 to 0.1.7
22+
* `exhaustive`: from 0.7.11 to 0.8.1
23+
* `gci`: fix issues and re-enable autofix
2024
* `gci`: from 0.3.4 to 0.4.2
21-
* `nonamedreturns`: from 1.0.1 to 1.0.4
22-
* `gocyclo`: from 0.5.1 to 0.6.0
2325
* `go-exhaustruct`: from 2.1.0 to 2.2.0
24-
* `errcheck`: from 1.6.0 to 1.6.1
25-
* `thelper`: from 0.6.2 to 0.6.3
26-
* `paralleltest`: from 1.0.3 to 1.0.6
27-
* `testpackage`: from 1.0.1 to 1.1.0
28-
* `exhaustive`: from 0.7.11 to 0.8.1
2926
* `go-ruleguard`: from 0.3.19 to 0.3.21
30-
* `gosec`: from 2.11.0 to 2.12.0
31-
* `tenv`: from 1.5.0 to 1.6.0
32-
* `wrapcheck`: from 2.6.1 to 2.6.2
3327
* `gocognit`: from 1.0.5 to 1.0.6
34-
* `decorder`: from 0.2.1 to 0.2.2
35-
* `honnef.co/go/tools`: from 0.3.1 to 0.3.2
28+
* `gocyclo`: from 0.5.1 to 0.6.0
3629
* `golang.org/x/tools`: bump to HEAD
37-
* `gci`: fix issues and re-enable autofix
3830
* `gosec`: allow `global` config
31+
* `gosec`: from 2.11.0 to 2.12.0
32+
* `nonamedreturns`: from 1.0.1 to 1.0.4
33+
* `paralleltest`: from 1.0.3 to 1.0.6
3934
* `staticcheck`: fix generics
35+
* `staticcheck`: from 0.3.1 to 0.3.2
36+
* `tenv`: from 1.5.0 to 1.6.0
37+
* `testpackage`: from 1.0.1 to 1.1.0
38+
* `thelper`: from 0.6.2 to 0.6.3
39+
* `wrapcheck`: from 2.6.1 to 2.6.2
4040
3. documentation:
4141
* add thanks page
4242
* add a clear explanation about the `staticcheck` integration.

pkg/golinters/revive.go

+42-10
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import (
77
"go/token"
88
"os"
99
"reflect"
10+
"strings"
1011
"sync"
1112

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

188189
normalizeConfig(conf)
190+
ignoreRules(conf)
189191

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

@@ -254,23 +256,23 @@ func safeTomlSlice(r []interface{}) []interface{} {
254256
// This element is not exported by revive, so we need copy the code.
255257
// Extracted from https://github.com/mgechev/revive/blob/v1.1.4/config/config.go#L15
256258
var defaultRules = []lint.Rule{
257-
&rule.VarDeclarationsRule{},
259+
// &rule.VarDeclarationsRule{}, // TODO(ldez) https://github.com/golangci/golangci-lint/issues/2997 (var-declaration)
258260
&rule.PackageCommentsRule{},
259261
&rule.DotImportsRule{},
260262
&rule.BlankImportsRule{},
261263
&rule.ExportedRule{},
262264
&rule.VarNamingRule{},
263265
&rule.IndentErrorFlowRule{},
264266
&rule.RangeRule{},
265-
&rule.ErrorfRule{},
267+
// &rule.ErrorfRule{}, // TODO(ldez) https://github.com/golangci/golangci-lint/issues/2997 (errorf
266268
&rule.ErrorNamingRule{},
267269
&rule.ErrorStringsRule{},
268270
&rule.ReceiverNamingRule{},
269271
&rule.IncrementDecrementRule{},
270272
&rule.ErrorReturnRule{},
271-
&rule.UnexportedReturnRule{},
272-
&rule.TimeNamingRule{},
273-
&rule.ContextKeysType{},
273+
// &rule.UnexportedReturnRule{}, // TODO(ldez) https://github.com/golangci/golangci-lint/issues/2997 (unexported-return)
274+
// &rule.TimeNamingRule{}, // TODO(ldez) https://github.com/golangci/golangci-lint/issues/2997 (time-naming)
275+
// &rule.ContextKeysType{}, // TODO(ldez) https://github.com/golangci/golangci-lint/issues/2997 (context-keys-type)
274276
&rule.ContextAsArgumentRule{},
275277
}
276278

@@ -291,15 +293,15 @@ var allRules = append([]lint.Rule{
291293
&rule.FlagParamRule{},
292294
&rule.UnnecessaryStmtRule{},
293295
&rule.StructTagRule{},
294-
&rule.ModifiesValRecRule{},
296+
// &rule.ModifiesValRecRule{}, // TODO(ldez) https://github.com/golangci/golangci-lint/issues/2997 (modifies-value-receiver)
295297
&rule.ConstantLogicalExprRule{},
296298
&rule.BoolLiteralRule{},
297299
&rule.RedefinesBuiltinIDRule{},
298300
&rule.ImportsBlacklistRule{},
299301
&rule.FunctionResultsLimitRule{},
300302
&rule.MaxPublicStructsRule{},
301303
&rule.RangeValInClosureRule{},
302-
&rule.RangeValAddress{},
304+
// &rule.RangeValAddress{}, // TODO(ldez) https://github.com/golangci/golangci-lint/issues/2997 (range-val-address)
303305
&rule.WaitGroupByValueRule{},
304306
&rule.AtomicRule{},
305307
&rule.EmptyLinesRule{},
@@ -309,9 +311,9 @@ var allRules = append([]lint.Rule{
309311
&rule.ImportShadowingRule{},
310312
&rule.BareReturnRule{},
311313
&rule.UnusedReceiverRule{},
312-
&rule.UnhandledErrorRule{},
314+
// &rule.UnhandledErrorRule{}, // TODO(ldez) https://github.com/golangci/golangci-lint/issues/2997 (unhandled-error)
313315
&rule.CognitiveComplexityRule{},
314-
&rule.StringOfIntRule{},
316+
// &rule.StringOfIntRule{}, // TODO(ldez) https://github.com/golangci/golangci-lint/issues/2997 (string-of-int)
315317
&rule.StringFormatRule{},
316318
&rule.EarlyReturnRule{},
317319
&rule.UnconditionalRecursionRule{},
@@ -322,7 +324,7 @@ var allRules = append([]lint.Rule{
322324
&rule.NestedStructs{},
323325
&rule.IfReturnRule{},
324326
&rule.UselessBreak{},
325-
&rule.TimeEqualRule{},
327+
// &rule.TimeEqualRule{}, // TODO(ldez) https://github.com/golangci/golangci-lint/issues/2997 (time-equal)
326328
&rule.BannedCharsRule{},
327329
&rule.OptimizeOperandsOrderRule{},
328330
}, defaultRules...)
@@ -388,3 +390,33 @@ func defaultConfig() *lint.Config {
388390
}
389391
return &defaultConfig
390392
}
393+
394+
// TODO(ldez) https://github.com/golangci/golangci-lint/issues/2997
395+
func ignoreRules(conf *lint.Config) {
396+
f := []string{
397+
"context-keys-type",
398+
"errorf",
399+
"modifies-value-receiver",
400+
"range-val-address",
401+
"string-of-int",
402+
"time-equal",
403+
"time-naming",
404+
"unexported-return",
405+
"unhandled-error",
406+
"var-declaration",
407+
}
408+
409+
var ignored []string
410+
for _, s := range f {
411+
if _, ok := conf.Rules[s]; ok {
412+
delete(conf.Rules, s)
413+
ignored = append(ignored, s)
414+
}
415+
}
416+
417+
if len(ignored) > 0 {
418+
linterLogger.Warnf("revive: the following rules (%s) are ignored due to a performance problem "+
419+
"(https://github.com/golangci/golangci-lint/issues/2997)",
420+
strings.Join(ignored, ","))
421+
}
422+
}

0 commit comments

Comments
 (0)