From 09a0302b079a396edcf82506cb549226df309855 Mon Sep 17 00:00:00 2001 From: Fernandez Ludovic Date: Sun, 27 Feb 2022 13:24:53 +0100 Subject: [PATCH] fix: add concurrency option --- .golangci.example.yml | 4 ++++ pkg/config/linters_settings.go | 18 +++++++++++++----- pkg/golinters/gosec.go | 2 +- 3 files changed, 18 insertions(+), 6 deletions(-) diff --git a/.golangci.example.yml b/.golangci.example.yml index 686cebda06d6..9aa6b7cc1364 100644 --- a/.golangci.example.yml +++ b/.golangci.example.yml @@ -720,6 +720,10 @@ linters-settings: # Default: low confidence: medium + # Concurrency value. + # Default: the number of logical CPUs usable by the current process. + concurrency: 12 + # To specify the configuration of rules. # The configuration of rules is not fully documented by gosec: # https://github.com/securego/gosec#configuration diff --git a/pkg/config/linters_settings.go b/pkg/config/linters_settings.go index 770183fbc967..bd5d11897f82 100644 --- a/pkg/config/linters_settings.go +++ b/pkg/config/linters_settings.go @@ -1,6 +1,10 @@ package config -import "github.com/pkg/errors" +import ( + "runtime" + + "github.com/pkg/errors" +) var defaultLintersSettings = LintersSettings{ Decorder: DecorderSettings{ @@ -47,6 +51,9 @@ var defaultLintersSettings = LintersSettings{ LangVersion: "", ExtraRules: false, }, + Gosec: GoSecSettings{ + Concurrency: runtime.NumCPU(), + }, Ifshort: IfshortSettings{ MaxDeclLines: 1, MaxDeclChars: 30, @@ -355,12 +362,13 @@ type GoModGuardSettings struct { } type GoSecSettings struct { - Includes []string - Excludes []string - Severity string - Confidence string + Includes []string `mapstructure:"includes"` + Excludes []string `mapstructure:"excludes"` + Severity string `mapstructure:"severity"` + Confidence string `mapstructure:"confidence"` ExcludeGenerated bool `mapstructure:"exclude-generated"` Config map[string]interface{} `mapstructure:"config"` + Concurrency int `mapstructure:"concurrency"` } type GovetSettings struct { diff --git a/pkg/golinters/gosec.go b/pkg/golinters/gosec.go index b220c30273e7..600a6e0f64fc 100644 --- a/pkg/golinters/gosec.go +++ b/pkg/golinters/gosec.go @@ -55,7 +55,7 @@ func NewGosec(settings *config.GoSecSettings) *goanalysis.Linter { nil, ).WithContextSetter(func(lintCtx *linter.Context) { analyzer.Run = func(pass *analysis.Pass) (interface{}, error) { - gosecAnalyzer := gosec.NewAnalyzer(gasConfig, true, settings.ExcludeGenerated, false, logger) + gosecAnalyzer := gosec.NewAnalyzer(gasConfig, true, settings.ExcludeGenerated, false, settings.Concurrency, logger) gosecAnalyzer.LoadRules(ruleDefinitions.RulesInfo()) pkg := &packages.Package{