Skip to content

Commit 808e1bf

Browse files
committed
review
1 parent 6e7c5bd commit 808e1bf

File tree

1 file changed

+28
-20
lines changed

1 file changed

+28
-20
lines changed

pkg/golinters/revive/revive.go

Lines changed: 28 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import (
99
"os"
1010
"reflect"
1111
"sort"
12+
"strings"
1213
"sync"
1314

1415
"github.com/BurntSushi/toml"
@@ -95,6 +96,8 @@ func newWrapper(settings *config.ReviveSettings) (*wrapper, error) {
9596
return nil, err
9697
}
9798

99+
displayRules(conf)
100+
98101
conf.GoVersion, err = hcversion.NewVersion(settings.Go)
99102
if err != nil {
100103
return nil, err
@@ -232,25 +235,14 @@ func getConfig(cfg *config.ReviveSettings) (*lint.Config, error) {
232235

233236
normalizeConfig(conf)
234237

235-
rulesEnabledByConfig := []string{}
236238
for k, r := range conf.Rules {
237239
err := r.Initialize()
238240
if err != nil {
239241
return nil, fmt.Errorf("error in config of rule %q: %w", k, err)
240242
}
241243
conf.Rules[k] = r
242-
243-
if !r.Disabled {
244-
rulesEnabledByConfig = append(rulesEnabledByConfig, k)
245-
}
246244
}
247245

248-
debugChecksListf(extractRulesName(allRules), "All available analyzers")
249-
debugChecksListf(extractRulesName(defaultRules), "Default analyzers")
250-
debugChecksListf(rulesEnabledByConfig, "Enabled by config analyzers")
251-
252-
debugf("revive configuration: %#v", conf)
253-
254246
return conf, nil
255247
}
256248

@@ -461,19 +453,35 @@ func defaultConfig() *lint.Config {
461453
return &defaultConfig
462454
}
463455

456+
func displayRules(conf *lint.Config) {
457+
if !isDebug {
458+
return
459+
}
460+
461+
var enabledRules []string
462+
for k, r := range conf.Rules {
463+
if !r.Disabled {
464+
enabledRules = append(enabledRules, k)
465+
}
466+
}
467+
468+
sort.Strings(enabledRules)
469+
470+
debugf("All available rules (%d): %s.", len(allRules), strings.Join(extractRulesName(allRules), ", "))
471+
debugf("Default rules (%d): %s.", len(allRules), strings.Join(extractRulesName(allRules), ", "))
472+
debugf("Enabled by config rules (%d): %s.", len(enabledRules), strings.Join(enabledRules, ", "))
473+
474+
debugf("revive configuration: %#v", conf)
475+
}
476+
464477
func extractRulesName(rules []lint.Rule) []string {
465-
names := []string{}
478+
var names []string
479+
466480
for _, r := range rules {
467481
names = append(names, r.Name())
468482
}
469-
return names
470-
}
471483

472-
func debugChecksListf(checks []string, format string, args ...any) {
473-
if !isDebug {
474-
return
475-
}
476-
sort.Strings(checks)
484+
sort.Strings(names)
477485

478-
debugf("%s checks (%d): %s", fmt.Sprintf(format, args...), len(checks), fmt.Sprint(checks))
486+
return names
479487
}

0 commit comments

Comments
 (0)