File tree Expand file tree Collapse file tree 3 files changed +19
-14
lines changed Expand file tree Collapse file tree 3 files changed +19
-14
lines changed Original file line number Diff line number Diff line change @@ -64,6 +64,7 @@ func (c *Config) Validate() error {
64
64
c .Run .Validate ,
65
65
c .Output .Validate ,
66
66
c .Linters .Validate ,
67
+ c .Formatters .Validate ,
67
68
c .Severity .Validate ,
68
69
}
69
70
Original file line number Diff line number Diff line change 1
1
package config
2
2
3
+ import (
4
+ "fmt"
5
+ "slices"
6
+ )
7
+
3
8
type Formatters struct {
4
9
Enable []string `mapstructure:"enable"`
5
10
Settings FormatterSettings `mapstructure:"settings"`
6
11
Exclusions FormatterExclusions `mapstructure:"exclusions"`
7
12
}
8
13
14
+ func (f * Formatters ) Validate () error {
15
+ for _ , n := range f .Enable {
16
+ if ! slices .Contains (getAllFormatterNames (), n ) {
17
+ return fmt .Errorf ("%s is a formatter" , n )
18
+ }
19
+ }
20
+
21
+ return nil
22
+ }
23
+
9
24
type FormatterExclusions struct {
10
25
Generated string `mapstructure:"generated"`
11
26
Paths []string `mapstructure:"paths"`
Original file line number Diff line number Diff line change @@ -26,8 +26,7 @@ type Linters struct {
26
26
func (l * Linters ) Validate () error {
27
27
validators := []func () error {
28
28
l .Exclusions .Validate ,
29
- l .validateNoFormattersEnabled ,
30
- l .validateNoFormattersDisabled ,
29
+ l .validateNoFormatters ,
31
30
}
32
31
33
32
for _ , v := range validators {
@@ -39,18 +38,8 @@ func (l *Linters) Validate() error {
39
38
return nil
40
39
}
41
40
42
- func (l * Linters ) validateNoFormattersEnabled () error {
43
- for _ , n := range l .Enable {
44
- if slices .Contains (getAllFormatterNames (), n ) {
45
- return fmt .Errorf ("%s is a formatter" , n )
46
- }
47
- }
48
-
49
- return nil
50
- }
51
-
52
- func (l * Linters ) validateNoFormattersDisabled () error {
53
- for _ , n := range l .Disable {
41
+ func (l * Linters ) validateNoFormatters () error {
42
+ for _ , n := range slices .Concat (l .Enable , l .Disable ) {
54
43
if slices .Contains (getAllFormatterNames (), n ) {
55
44
return fmt .Errorf ("%s is a formatter" , n )
56
45
}
You can’t perform that action at this time.
0 commit comments