Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions pkg/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ func (c *Config) Validate() error {
c.Run.Validate,
c.Output.Validate,
c.Linters.Validate,
c.Formatters.Validate,
c.Severity.Validate,
}

Expand Down
15 changes: 15 additions & 0 deletions pkg/config/formatters.go
Original file line number Diff line number Diff line change
@@ -1,11 +1,26 @@
package config

import (
"fmt"
"slices"
)

type Formatters struct {
Enable []string `mapstructure:"enable"`
Settings FormatterSettings `mapstructure:"settings"`
Exclusions FormatterExclusions `mapstructure:"exclusions"`
}

func (f *Formatters) Validate() error {
for _, n := range f.Enable {
if !slices.Contains(getAllFormatterNames(), n) {
return fmt.Errorf("%s is a formatter", n)
}
}

return nil
}

type FormatterExclusions struct {
Generated string `mapstructure:"generated"`
Paths []string `mapstructure:"paths"`
Expand Down
19 changes: 4 additions & 15 deletions pkg/config/linters.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,7 @@ type Linters struct {
func (l *Linters) Validate() error {
validators := []func() error{
l.Exclusions.Validate,
l.validateNoFormattersEnabled,
l.validateNoFormattersDisabled,
l.validateNoFormatters,
}

for _, v := range validators {
Expand All @@ -39,18 +38,8 @@ func (l *Linters) Validate() error {
return nil
}

func (l *Linters) validateNoFormattersEnabled() error {
for _, n := range l.Enable {
if slices.Contains(getAllFormatterNames(), n) {
return fmt.Errorf("%s is a formatter", n)
}
}

return nil
}

func (l *Linters) validateNoFormattersDisabled() error {
for _, n := range l.Disable {
func (l *Linters) validateNoFormatters() error {
for _, n := range slices.Concat(l.Enable, l.Disable) {
if slices.Contains(getAllFormatterNames(), n) {
return fmt.Errorf("%s is a formatter", n)
}
Expand All @@ -60,5 +49,5 @@ func (l *Linters) validateNoFormattersDisabled() error {
}

func getAllFormatterNames() []string {
return []string{"gci", "gofmt", "gofumpt", "goimports"}
return []string{"gci", "gofmt", "gofumpt", "goimports", "golines"}
}
Loading