Skip to content

dev: minor clean up #4492

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Mar 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .golangci.next.reference.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
73 changes: 39 additions & 34 deletions cmd/golangci-lint/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,42 +35,47 @@ func createBuildInfo() commands.BuildInfo {
Date: date,
}

if buildInfo, available := debug.ReadBuildInfo(); available {
info.GoVersion = buildInfo.GoVersion

if date == "" {
info.Version = buildInfo.Main.Version

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 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)
buildInfo, available := debug.ReadBuildInfo()
if !available {
return info
}

info.GoVersion = buildInfo.GoVersion

if date != "" {
return info
}

info.Version = buildInfo.Main.Version

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
}
2 changes: 1 addition & 1 deletion docs/src/docs/usage/install/index.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -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.

Expand Down
7 changes: 6 additions & 1 deletion pkg/commands/run.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand Down
2 changes: 1 addition & 1 deletion pkg/result/processors/severity.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand Down
Loading