Skip to content

Commit

Permalink
fix: add concurrency option
Browse files Browse the repository at this point in the history
  • Loading branch information
ldez committed Feb 27, 2022
1 parent 62206bf commit 629c7a6
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 6 deletions.
4 changes: 4 additions & 0 deletions .golangci.example.yml
Expand Up @@ -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
Expand Down
18 changes: 13 additions & 5 deletions 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{
Expand Down Expand Up @@ -47,6 +51,9 @@ var defaultLintersSettings = LintersSettings{
LangVersion: "",
ExtraRules: false,
},
Gosec: GoSecSettings{
Concurrency: runtime.NumCPU(),
},
Ifshort: IfshortSettings{
MaxDeclLines: 1,
MaxDeclChars: 30,
Expand Down Expand Up @@ -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 {
Expand Down
2 changes: 1 addition & 1 deletion pkg/golinters/gosec.go
Expand Up @@ -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{
Expand Down

0 comments on commit 629c7a6

Please sign in to comment.