From 93c28aac23836dd4f374e2d55632014f40808840 Mon Sep 17 00:00:00 2001 From: Fernandez Ludovic Date: Wed, 16 Feb 2022 00:03:36 +0100 Subject: [PATCH 1/5] bump github.com/mgechev/revive from v1.1.3 to v1.1.4 --- go.mod | 2 +- go.sum | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index e09ce7831326..f01ade89d1c1 100644 --- a/go.mod +++ b/go.mod @@ -56,7 +56,7 @@ require ( github.com/mattn/go-colorable v0.1.12 github.com/mbilski/exhaustivestruct v1.2.0 github.com/mgechev/dots v0.0.0-20210922191527-e955255bf517 - github.com/mgechev/revive v1.1.3 + github.com/mgechev/revive v1.1.4 github.com/mitchellh/go-homedir v1.1.0 github.com/mitchellh/go-ps v1.0.0 github.com/moricho/tparallel v0.2.1 diff --git a/go.sum b/go.sum index a5c488cf8828..810afe35afba 100644 --- a/go.sum +++ b/go.sum @@ -539,8 +539,8 @@ github.com/mbilski/exhaustivestruct v1.2.0 h1:wCBmUnSYufAHO6J4AVWY6ff+oxWxsVFrwg github.com/mbilski/exhaustivestruct v1.2.0/go.mod h1:OeTBVxQWoEmB2J2JCHmXWPJ0aksxSUOUy+nvtVEfzXc= github.com/mgechev/dots v0.0.0-20210922191527-e955255bf517 h1:zpIH83+oKzcpryru8ceC6BxnoG8TBrhgAvRg8obzup0= github.com/mgechev/dots v0.0.0-20210922191527-e955255bf517/go.mod h1:KQ7+USdGKfpPjXk4Ga+5XxQM4Lm4e3gAogrreFAYpOg= -github.com/mgechev/revive v1.1.3 h1:6tBZacs2/uv9UOpkBQhCtXh2NGgu2Ry97ZyjcN6uDCM= -github.com/mgechev/revive v1.1.3/go.mod h1:jMzDa13teAuv/KLeqgJw79NDe+1IT0ZO3Mht0vN1Yls= +github.com/mgechev/revive v1.1.4 h1:sZOjY6GU35Kr9jKa/wsKSHgrFz8eASIB5i3tqWZMp0A= +github.com/mgechev/revive v1.1.4/go.mod h1:ZZq2bmyssGh8MSPz3VVziqRNIMYTJXzP8MUKG90vZ9A= github.com/miekg/dns v1.0.14/go.mod h1:W1PPwlIAgtquWBMBEV9nkV9Cazfe8ScdGz/Lj7v3Nrg= github.com/miekg/dns v1.1.26/go.mod h1:bPDLeHnStXmXAq1m/Ch/hvfNHr14JKNPMBo3VZKjuso= github.com/miekg/dns v1.1.35/go.mod h1:KNUDUusw/aVsxyTYZM1oqvCicbwhgbNgztCETuNZ7xM= From da0e8534cf340ccf39d21807e3a76fc088bba50b Mon Sep 17 00:00:00 2001 From: Fernandez Ludovic Date: Thu, 27 Jan 2022 01:13:12 +0100 Subject: [PATCH 2/5] docs(revive): missing rule --- .golangci.example.yml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/.golangci.example.yml b/.golangci.example.yml index b9d9db63ef87..a625caa7946b 100644 --- a/.golangci.example.yml +++ b/.golangci.example.yml @@ -1042,6 +1042,11 @@ linters-settings: allowInts: "0,1,2" allowFloats: "0.0,0.,1.0,1.,2.0,2." # https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#atomic + - name: argument-limit + severity: warning + disabled: false + arguments: [4] + # https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#atomic - name: atomic severity: warning disabled: false From 20a1182d56acedc03ed054c08a626797d52ed7c1 Mon Sep 17 00:00:00 2001 From: Fernandez Ludovic Date: Thu, 27 Jan 2022 01:13:33 +0100 Subject: [PATCH 3/5] chore: update code from revive --- pkg/golinters/revive.go | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) diff --git a/pkg/golinters/revive.go b/pkg/golinters/revive.go index 5b1e0c091b66..6c7898ba0a0e 100644 --- a/pkg/golinters/revive.go +++ b/pkg/golinters/revive.go @@ -148,7 +148,7 @@ func reviveToIssue(pass *analysis.Pass, object *jsonObject) goanalysis.Issue { // This function mimics the GetConfig function of revive. // This allows to get default values and right types. // https://github.com/golangci/golangci-lint/issues/1745 -// https://github.com/mgechev/revive/blob/389ba853b0b3587f0c3b71b5f0c61ea4e23928ec/config/config.go#L155 +// https://github.com/mgechev/revive/blob/v1.1.4/config/config.go#L182 func getReviveConfig(cfg *config.ReviveSettings) (*lint.Config, error) { conf := defaultConfig() @@ -235,7 +235,7 @@ 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/111721be475b73b5a2304dd01ccbcab587357fca/config/config.go#L15 +// Extracted from https://github.com/mgechev/revive/blob/v1.1.4/config/config.go#L15 var defaultRules = []lint.Rule{ &rule.VarDeclarationsRule{}, &rule.PackageCommentsRule{}, @@ -310,14 +310,11 @@ var allRules = append([]lint.Rule{ &rule.OptimizeOperandsOrderRule{}, }, defaultRules...) +const defaultConfidence = 0.8 + // This element is not exported by revive, so we need copy the code. -// Extracted from https://github.com/mgechev/revive/blob/111721be475b73b5a2304dd01ccbcab587357fca/config/config.go#L143 +// Extracted from https://github.com/mgechev/revive/blob/v1.1.4/config/config.go#L145 func normalizeConfig(cfg *lint.Config) { - const defaultConfidence = 0.8 - if cfg.Confidence == 0 { - cfg.Confidence = defaultConfidence - } - if len(cfg.Rules) == 0 { cfg.Rules = map[string]lint.RuleConfig{} } @@ -352,10 +349,10 @@ func normalizeConfig(cfg *lint.Config) { } // This element is not exported by revive, so we need copy the code. -// Extracted from https://github.com/mgechev/revive/blob/111721be475b73b5a2304dd01ccbcab587357fca/config/config.go#L210 +// Extracted from https://github.com/mgechev/revive/blob/v1.1.4/config/config.go#L214 func defaultConfig() *lint.Config { defaultConfig := lint.Config{ - Confidence: 0.0, + Confidence: defaultConfidence, Severity: lint.SeverityWarning, Rules: map[string]lint.RuleConfig{}, } From 1563a253da75051f7e007405f072abb096c0a826 Mon Sep 17 00:00:00 2001 From: Fernandez Ludovic Date: Wed, 16 Feb 2022 00:22:17 +0100 Subject: [PATCH 4/5] feat: add MaxOpenFiles option --- pkg/config/linters_settings.go | 1 + pkg/golinters/revive.go | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/pkg/config/linters_settings.go b/pkg/config/linters_settings.go index da7237da66d6..71e5ed131af1 100644 --- a/pkg/config/linters_settings.go +++ b/pkg/config/linters_settings.go @@ -480,6 +480,7 @@ type PromlinterSettings struct { } type ReviveSettings struct { + MaxOpenFiles int `mapstructure:"max-open-files"` IgnoreGeneratedHeader bool `mapstructure:"ignore-generated-header"` Confidence float64 Severity string diff --git a/pkg/golinters/revive.go b/pkg/golinters/revive.go index 6c7898ba0a0e..d8165f3cede7 100644 --- a/pkg/golinters/revive.go +++ b/pkg/golinters/revive.go @@ -65,7 +65,7 @@ func NewRevive(cfg *config.ReviveSettings) *goanalysis.Linter { return nil, err } - revive := lint.New(os.ReadFile) + revive := lint.New(os.ReadFile, cfg.MaxOpenFiles) lintingRules, err := reviveConfig.GetLintingRules(conf) if err != nil { From 9ebb389a02fdea9aa224a1162458832cc3ff2784 Mon Sep 17 00:00:00 2001 From: Fernandez Ludovic Date: Wed, 16 Feb 2022 00:28:45 +0100 Subject: [PATCH 5/5] doc: max-open-files --- .golangci.example.yml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.golangci.example.yml b/.golangci.example.yml index a625caa7946b..231dbf215214 100644 --- a/.golangci.example.yml +++ b/.golangci.example.yml @@ -1024,6 +1024,10 @@ linters-settings: - UnitAbbreviations revive: + # Maximum number of open files at the same time. + # https://github.com/mgechev/revive#command-line-flags + # Defaults to unlimited. + max-open-files: 2048 # See https://github.com/mgechev/revive#available-rules for details. ignore-generated-header: true severity: warning