diff --git a/.golangci.next.reference.yml b/.golangci.next.reference.yml index 4fbbe8fa..71dff87c 100644 --- a/.golangci.next.reference.yml +++ b/.golangci.next.reference.yml @@ -6,7 +6,7 @@ # Options for analysis running. run: - # Number of operating system threads (`GOMAXPROCS`) that can execute golangci-lint simultaneously. + # Number of operating system threads (`GOMAXPROCS`) that can execute golangci-lint simultaneously. # If it is explicitly set to 0 (i.e. not the default) then golangci-lint will automatically set the value to match Linux container CPU quota. # Default: the number of logical CPUs in the machine concurrency: 4 diff --git a/cmd/golangci-lint/main.go b/cmd/golangci-lint/main.go index 57d61f17..c383f93e 100644 --- a/cmd/golangci-lint/main.go +++ b/cmd/golangci-lint/main.go @@ -35,42 +35,47 @@ func createBuildInfo() commands.BuildInfo { Date: date, } - if buildInfo, available := debug.ReadBuildInfo(); available { - info.GoVersion = buildInfo.GoVersion + buildInfo, available := debug.ReadBuildInfo() + if !available { + return info + } - if date == "" { - info.Version = buildInfo.Main.Version + info.GoVersion = buildInfo.GoVersion - var revision string - var modified string - for _, setting := range buildInfo.Settings { - // The `vcs.xxx` information is only available with `go build`. - // This information is are not available with `go install` or `go run`. - switch setting.Key { - case "vcs.time": - info.Date = setting.Value - case "vcs.revision": - revision = setting.Value - case "vcs.modified": - modified = setting.Value - } - } + if date != "" { + return info + } - if revision == "" { - revision = "unknown" - } + info.Version = buildInfo.Main.Version - if modified == "" { - modified = "?" - } - - if info.Date == "" { - info.Date = "(unknown)" - } - - info.Commit = fmt.Sprintf("(%s, modified: %s, mod sum: %q)", revision, modified, buildInfo.Main.Sum) + var revision string + var modified string + for _, setting := range buildInfo.Settings { + // The `vcs.xxx` information is only available with `go build`. + // This information is not available with `go install` or `go run`. + switch setting.Key { + case "vcs.time": + info.Date = setting.Value + case "vcs.revision": + revision = setting.Value + case "vcs.modified": + modified = setting.Value } } + if revision == "" { + revision = "unknown" + } + + if modified == "" { + modified = "?" + } + + if info.Date == "" { + info.Date = "(unknown)" + } + + info.Commit = fmt.Sprintf("(%s, modified: %s, mod sum: %q)", revision, modified, buildInfo.Main.Sum) + return info } diff --git a/docs/src/docs/usage/install/index.mdx b/docs/src/docs/usage/install/index.mdx index f1075e8a..efd13f6c 100644 --- a/docs/src/docs/usage/install/index.mdx +++ b/docs/src/docs/usage/install/index.mdx @@ -167,7 +167,7 @@ Each phase corresponds to a minor version: - v1.1.0 -> error message - v1.2.0 -> linter removed -Otherwise, the deprecated linters are removed from presets immediately when they are deprecated (phase 1). +The deprecated linters are removed from presets immediately when they are deprecated (phase 1). We will provide clear information about those changes on different supports: changelog, logs, social network, etc. diff --git a/pkg/commands/run.go b/pkg/commands/run.go index 610a9e9e..410170aa 100644 --- a/pkg/commands/run.go +++ b/pkg/commands/run.go @@ -159,8 +159,13 @@ func (c *runCommand) persistentPreRunE(cmd *cobra.Command, _ []string) error { } if c.cfg.Run.Concurrency == 0 { + backup := runtime.GOMAXPROCS(0) + // Automatically set GOMAXPROCS to match Linux container CPU quota. - _, _ = maxprocs.Set(maxprocs.Logger(c.log.Infof)) + _, err := maxprocs.Set(maxprocs.Logger(c.log.Infof)) + if err != nil { + runtime.GOMAXPROCS(backup) + } } else { runtime.GOMAXPROCS(c.cfg.Run.Concurrency) } diff --git a/pkg/result/processors/severity.go b/pkg/result/processors/severity.go index f087f951..2568ba45 100644 --- a/pkg/result/processors/severity.go +++ b/pkg/result/processors/severity.go @@ -69,7 +69,7 @@ func (p *Severity) Process(issues []result.Issue) ([]result.Issue, error) { func (p *Severity) transform(issue *result.Issue) *result.Issue { for _, rule := range p.rules { if rule.match(issue, p.files, p.log) { - if rule.severity == severityFromLinter || rule.severity == "" && p.defaultSeverity == severityFromLinter { + if rule.severity == severityFromLinter || (rule.severity == "" && p.defaultSeverity == severityFromLinter) { return issue }