Skip to content

Commit 629c7a6

Browse files
committed
fix: add concurrency option
1 parent 62206bf commit 629c7a6

File tree

3 files changed

+18
-6
lines changed

3 files changed

+18
-6
lines changed

.golangci.example.yml

+4
Original file line numberDiff line numberDiff line change
@@ -720,6 +720,10 @@ linters-settings:
720720
# Default: low
721721
confidence: medium
722722

723+
# Concurrency value.
724+
# Default: the number of logical CPUs usable by the current process.
725+
concurrency: 12
726+
723727
# To specify the configuration of rules.
724728
# The configuration of rules is not fully documented by gosec:
725729
# https://github.com/securego/gosec#configuration

pkg/config/linters_settings.go

+13-5
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
package config
22

3-
import "github.com/pkg/errors"
3+
import (
4+
"runtime"
5+
6+
"github.com/pkg/errors"
7+
)
48

59
var defaultLintersSettings = LintersSettings{
610
Decorder: DecorderSettings{
@@ -47,6 +51,9 @@ var defaultLintersSettings = LintersSettings{
4751
LangVersion: "",
4852
ExtraRules: false,
4953
},
54+
Gosec: GoSecSettings{
55+
Concurrency: runtime.NumCPU(),
56+
},
5057
Ifshort: IfshortSettings{
5158
MaxDeclLines: 1,
5259
MaxDeclChars: 30,
@@ -355,12 +362,13 @@ type GoModGuardSettings struct {
355362
}
356363

357364
type GoSecSettings struct {
358-
Includes []string
359-
Excludes []string
360-
Severity string
361-
Confidence string
365+
Includes []string `mapstructure:"includes"`
366+
Excludes []string `mapstructure:"excludes"`
367+
Severity string `mapstructure:"severity"`
368+
Confidence string `mapstructure:"confidence"`
362369
ExcludeGenerated bool `mapstructure:"exclude-generated"`
363370
Config map[string]interface{} `mapstructure:"config"`
371+
Concurrency int `mapstructure:"concurrency"`
364372
}
365373

366374
type GovetSettings struct {

pkg/golinters/gosec.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ func NewGosec(settings *config.GoSecSettings) *goanalysis.Linter {
5555
nil,
5656
).WithContextSetter(func(lintCtx *linter.Context) {
5757
analyzer.Run = func(pass *analysis.Pass) (interface{}, error) {
58-
gosecAnalyzer := gosec.NewAnalyzer(gasConfig, true, settings.ExcludeGenerated, false, logger)
58+
gosecAnalyzer := gosec.NewAnalyzer(gasConfig, true, settings.ExcludeGenerated, false, settings.Concurrency, logger)
5959
gosecAnalyzer.LoadRules(ruleDefinitions.RulesInfo())
6060

6161
pkg := &packages.Package{

0 commit comments

Comments
 (0)