|
9 | 9 | "os" |
10 | 10 | "reflect" |
11 | 11 | "sort" |
| 12 | + "strings" |
12 | 13 | "sync" |
13 | 14 |
|
14 | 15 | "github.com/BurntSushi/toml" |
@@ -95,6 +96,8 @@ func newWrapper(settings *config.ReviveSettings) (*wrapper, error) { |
95 | 96 | return nil, err |
96 | 97 | } |
97 | 98 |
|
| 99 | + displayRules(conf) |
| 100 | + |
98 | 101 | conf.GoVersion, err = hcversion.NewVersion(settings.Go) |
99 | 102 | if err != nil { |
100 | 103 | return nil, err |
@@ -232,25 +235,14 @@ func getConfig(cfg *config.ReviveSettings) (*lint.Config, error) { |
232 | 235 |
|
233 | 236 | normalizeConfig(conf) |
234 | 237 |
|
235 | | - rulesEnabledByConfig := []string{} |
236 | 238 | for k, r := range conf.Rules { |
237 | 239 | err := r.Initialize() |
238 | 240 | if err != nil { |
239 | 241 | return nil, fmt.Errorf("error in config of rule %q: %w", k, err) |
240 | 242 | } |
241 | 243 | conf.Rules[k] = r |
242 | | - |
243 | | - if !r.Disabled { |
244 | | - rulesEnabledByConfig = append(rulesEnabledByConfig, k) |
245 | | - } |
246 | 244 | } |
247 | 245 |
|
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 | | - |
254 | 246 | return conf, nil |
255 | 247 | } |
256 | 248 |
|
@@ -461,19 +453,35 @@ func defaultConfig() *lint.Config { |
461 | 453 | return &defaultConfig |
462 | 454 | } |
463 | 455 |
|
| 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 | + |
464 | 477 | func extractRulesName(rules []lint.Rule) []string { |
465 | | - names := []string{} |
| 478 | + var names []string |
| 479 | + |
466 | 480 | for _, r := range rules { |
467 | 481 | names = append(names, r.Name()) |
468 | 482 | } |
469 | | - return names |
470 | | -} |
471 | 483 |
|
472 | | -func debugChecksListf(checks []string, format string, args ...any) { |
473 | | - if !isDebug { |
474 | | - return |
475 | | - } |
476 | | - sort.Strings(checks) |
| 484 | + sort.Strings(names) |
477 | 485 |
|
478 | | - debugf("%s checks (%d): %s", fmt.Sprintf(format, args...), len(checks), fmt.Sprint(checks)) |
| 486 | + return names |
479 | 487 | } |
0 commit comments