Skip to content

Commit 0554536

Browse files
authored
dev: minor clean up (#4492)
1 parent 331d29b commit 0554536

File tree

5 files changed

+48
-38
lines changed

5 files changed

+48
-38
lines changed

.golangci.next.reference.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
# Options for analysis running.
88
run:
9-
# Number of operating system threads (`GOMAXPROCS`) that can execute golangci-lint simultaneously.
9+
# Number of operating system threads (`GOMAXPROCS`) that can execute golangci-lint simultaneously.
1010
# 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.
1111
# Default: the number of logical CPUs in the machine
1212
concurrency: 4

cmd/golangci-lint/main.go

Lines changed: 39 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -35,42 +35,47 @@ func createBuildInfo() commands.BuildInfo {
3535
Date: date,
3636
}
3737

38-
if buildInfo, available := debug.ReadBuildInfo(); available {
39-
info.GoVersion = buildInfo.GoVersion
40-
41-
if date == "" {
42-
info.Version = buildInfo.Main.Version
43-
44-
var revision string
45-
var modified string
46-
for _, setting := range buildInfo.Settings {
47-
// The `vcs.xxx` information is only available with `go build`.
48-
// This information is are not available with `go install` or `go run`.
49-
switch setting.Key {
50-
case "vcs.time":
51-
info.Date = setting.Value
52-
case "vcs.revision":
53-
revision = setting.Value
54-
case "vcs.modified":
55-
modified = setting.Value
56-
}
57-
}
58-
59-
if revision == "" {
60-
revision = "unknown"
61-
}
62-
63-
if modified == "" {
64-
modified = "?"
65-
}
66-
67-
if info.Date == "" {
68-
info.Date = "(unknown)"
69-
}
70-
71-
info.Commit = fmt.Sprintf("(%s, modified: %s, mod sum: %q)", revision, modified, buildInfo.Main.Sum)
38+
buildInfo, available := debug.ReadBuildInfo()
39+
if !available {
40+
return info
41+
}
42+
43+
info.GoVersion = buildInfo.GoVersion
44+
45+
if date != "" {
46+
return info
47+
}
48+
49+
info.Version = buildInfo.Main.Version
50+
51+
var revision string
52+
var modified string
53+
for _, setting := range buildInfo.Settings {
54+
// The `vcs.xxx` information is only available with `go build`.
55+
// This information is not available with `go install` or `go run`.
56+
switch setting.Key {
57+
case "vcs.time":
58+
info.Date = setting.Value
59+
case "vcs.revision":
60+
revision = setting.Value
61+
case "vcs.modified":
62+
modified = setting.Value
7263
}
7364
}
7465

66+
if revision == "" {
67+
revision = "unknown"
68+
}
69+
70+
if modified == "" {
71+
modified = "?"
72+
}
73+
74+
if info.Date == "" {
75+
info.Date = "(unknown)"
76+
}
77+
78+
info.Commit = fmt.Sprintf("(%s, modified: %s, mod sum: %q)", revision, modified, buildInfo.Main.Sum)
79+
7580
return info
7681
}

docs/src/docs/usage/install/index.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,7 @@ Each phase corresponds to a minor version:
167167
- v1.1.0 -> error message
168168
- v1.2.0 -> linter removed
169169

170-
Otherwise, the deprecated linters are removed from presets immediately when they are deprecated (phase 1).
170+
The deprecated linters are removed from presets immediately when they are deprecated (phase 1).
171171

172172
We will provide clear information about those changes on different supports: changelog, logs, social network, etc.
173173

pkg/commands/run.go

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -159,8 +159,13 @@ func (c *runCommand) persistentPreRunE(cmd *cobra.Command, _ []string) error {
159159
}
160160

161161
if c.cfg.Run.Concurrency == 0 {
162+
backup := runtime.GOMAXPROCS(0)
163+
162164
// Automatically set GOMAXPROCS to match Linux container CPU quota.
163-
_, _ = maxprocs.Set(maxprocs.Logger(c.log.Infof))
165+
_, err := maxprocs.Set(maxprocs.Logger(c.log.Infof))
166+
if err != nil {
167+
runtime.GOMAXPROCS(backup)
168+
}
164169
} else {
165170
runtime.GOMAXPROCS(c.cfg.Run.Concurrency)
166171
}

pkg/result/processors/severity.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ func (p *Severity) Process(issues []result.Issue) ([]result.Issue, error) {
6969
func (p *Severity) transform(issue *result.Issue) *result.Issue {
7070
for _, rule := range p.rules {
7171
if rule.match(issue, p.files, p.log) {
72-
if rule.severity == severityFromLinter || rule.severity == "" && p.defaultSeverity == severityFromLinter {
72+
if rule.severity == severityFromLinter || (rule.severity == "" && p.defaultSeverity == severityFromLinter) {
7373
return issue
7474
}
7575

0 commit comments

Comments
 (0)