dev: minor clean up (#4492)

This commit is contained in:
Ludovic Fernandez 2024-03-12 23:38:14 +01:00 committed by GitHub
parent 331d29bee3
commit 0554536620
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
5 changed files with 44 additions and 34 deletions

View File

@ -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

View File

@ -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
}

View File

@ -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.

View File

@ -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)
}

View File

@ -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
}