Skip to content

Commit fe72773

Browse files
committed
dev log consistency
1 parent 6d29861 commit fe72773

File tree

2 files changed

+14
-14
lines changed

2 files changed

+14
-14
lines changed

pkg/golinters/gocritic/gocritic.go

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,7 @@ func (w *goCriticWrapper) buildEnabledCheckers(linterCtx *gocriticlinter.Context
133133
if err != nil {
134134
return nil, err
135135
}
136+
136137
enabledCheckers = append(enabledCheckers, c)
137138
}
138139

@@ -294,6 +295,7 @@ func (s *settingsWrapper) InferEnabledChecks() {
294295
s.debugChecksInitialState()
295296

296297
enabledByDefaultChecks, disabledByDefaultChecks := s.buildEnabledAndDisabledByDefaultChecks()
298+
297299
debugChecksListf(enabledByDefaultChecks, "Enabled by default")
298300
debugChecksListf(disabledByDefaultChecks, "Disabled by default")
299301

@@ -314,7 +316,7 @@ func (s *settingsWrapper) InferEnabledChecks() {
314316

315317
if len(s.EnabledTags) != 0 {
316318
enabledFromTags := s.expandTagsToChecks(s.EnabledTags)
317-
debugChecksListf(enabledFromTags, "Enabled by config tags %s", sprintSortedStrings(s.EnabledTags))
319+
debugChecksListf(enabledFromTags, "Enabled by config tags %s", s.EnabledTags)
318320

319321
for _, check := range enabledFromTags {
320322
enabledChecks[check] = struct{}{}
@@ -335,7 +337,7 @@ func (s *settingsWrapper) InferEnabledChecks() {
335337

336338
if len(s.DisabledTags) != 0 {
337339
disabledFromTags := s.expandTagsToChecks(s.DisabledTags)
338-
debugChecksListf(disabledFromTags, "Disabled by config tags %s", sprintSortedStrings(s.DisabledTags))
340+
debugChecksListf(disabledFromTags, "Disabled by config tags %s", s.DisabledTags)
339341

340342
for _, check := range disabledFromTags {
341343
delete(enabledChecks, check)
@@ -549,10 +551,8 @@ func debugChecksListf(checks []string, format string, args ...any) {
549551
return
550552
}
551553

552-
debugf("%s checks (%d): %s", fmt.Sprintf(format, args...), len(checks), sprintSortedStrings(checks))
553-
}
554+
v := slices.Clone(checks)
555+
slices.Sort(v)
554556

555-
func sprintSortedStrings(v []string) string {
556-
sort.Strings(slices.Clone(v))
557-
return fmt.Sprint(v)
557+
debugf("%s checks (%d): %s", fmt.Sprintf(format, args...), len(checks), strings.Join(v, ", "))
558558
}

pkg/golinters/govet/govet.go

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ package govet
22

33
import (
44
"slices"
5-
"sort"
5+
"strings"
66

77
"golang.org/x/tools/go/analysis"
88
"golang.org/x/tools/go/analysis/passes/appends"
@@ -164,8 +164,8 @@ func New(settings *config.GovetSettings) *goanalysis.Linter {
164164
}
165165

166166
func analyzersFromConfig(settings *config.GovetSettings) []*analysis.Analyzer {
167-
debugAnalyzersListf(allAnalyzers, "All available analyzers")
168-
debugAnalyzersListf(defaultAnalyzers, "Default analyzers")
167+
logAnalyzers("All available analyzers", allAnalyzers)
168+
logAnalyzers("Default analyzers", defaultAnalyzers)
169169

170170
if settings == nil {
171171
return defaultAnalyzers
@@ -178,7 +178,7 @@ func analyzersFromConfig(settings *config.GovetSettings) []*analysis.Analyzer {
178178
}
179179
}
180180

181-
debugAnalyzersListf(enabledAnalyzers, "Enabled by config analyzers")
181+
logAnalyzers("Enabled by config analyzers", enabledAnalyzers)
182182

183183
return enabledAnalyzers
184184
}
@@ -212,7 +212,7 @@ func isAnalyzerEnabled(name string, cfg *config.GovetSettings, defaultAnalyzers
212212
}
213213
}
214214

215-
func debugAnalyzersListf(analyzers []*analysis.Analyzer, message string) {
215+
func logAnalyzers(message string, analyzers []*analysis.Analyzer) {
216216
if !isDebug {
217217
return
218218
}
@@ -222,7 +222,7 @@ func debugAnalyzersListf(analyzers []*analysis.Analyzer, message string) {
222222
analyzerNames = append(analyzerNames, a.Name)
223223
}
224224

225-
sort.Strings(analyzerNames)
225+
slices.Sort(analyzerNames)
226226

227-
debugf("%s (%d): %s", message, len(analyzerNames), analyzerNames)
227+
debugf("%s (%d): %s", message, len(analyzerNames), strings.Join(analyzerNames, ", "))
228228
}

0 commit comments

Comments
 (0)