8
8
"go/token"
9
9
"os"
10
10
"reflect"
11
+ "slices"
12
+ "strings"
11
13
"sync"
12
14
13
15
"github.com/BurntSushi/toml"
@@ -27,7 +29,10 @@ import (
27
29
28
30
const linterName = "revive"
29
31
30
- var debugf = logutils .Debug (logutils .DebugKeyRevive )
32
+ var (
33
+ debugf = logutils .Debug (logutils .DebugKeyRevive )
34
+ isDebug = logutils .HaveDebugTag (logutils .DebugKeyRevive )
35
+ )
31
36
32
37
// jsonObject defines a JSON object of a failure
33
38
type jsonObject struct {
@@ -91,6 +96,8 @@ func newWrapper(settings *config.ReviveSettings) (*wrapper, error) {
91
96
return nil , err
92
97
}
93
98
99
+ displayRules (conf )
100
+
94
101
conf .GoVersion , err = hcversion .NewVersion (settings .Go )
95
102
if err != nil {
96
103
return nil , err
@@ -236,8 +243,6 @@ func getConfig(cfg *config.ReviveSettings) (*lint.Config, error) {
236
243
conf .Rules [k ] = r
237
244
}
238
245
239
- debugf ("revive configuration: %#v" , conf )
240
-
241
246
return conf , nil
242
247
}
243
248
@@ -447,3 +452,36 @@ func defaultConfig() *lint.Config {
447
452
}
448
453
return & defaultConfig
449
454
}
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
+ slices .Sort (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
+
477
+ func extractRulesName (rules []lint.Rule ) []string {
478
+ var names []string
479
+
480
+ for _ , r := range rules {
481
+ names = append (names , r .Name ())
482
+ }
483
+
484
+ slices .Sort (names )
485
+
486
+ return names
487
+ }
0 commit comments