diff --git a/.golangci.yml b/.golangci.yml index 2e72bba..f2b322d 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -64,6 +64,11 @@ linters-settings: section-separators: - newLine + gocritic: + disable-all: true + enabled-checks: + # suggest removing unnecessary strings.Compare + - stringsCompare gofmt: # simplify code: gofmt with `-s` option, true by default simplify: true @@ -75,11 +80,12 @@ linters-settings: linters: fast: false enable: + - gocritic - gofmt - gofumpt - goimports - gci disable-all: true - + issues: exclude: diff --git a/pkg/config/config.go b/pkg/config/config.go index 814201a..643a313 100644 --- a/pkg/config/config.go +++ b/pkg/config/config.go @@ -2,7 +2,6 @@ package config import ( "sort" - "strings" "gopkg.in/yaml.v3" @@ -64,11 +63,11 @@ func (g YamlConfig) Parse() (*Config, error) { sort.Slice(sections, func(i, j int) bool { sectionI, sectionJ := sections[i].Type(), sections[j].Type() - if g.Cfg.NoLexOrder || strings.Compare(sectionI, sectionJ) != 0 { + if g.Cfg.NoLexOrder || sectionI != sectionJ { return defaultOrder[sectionI] < defaultOrder[sectionJ] } - return strings.Compare(sections[i].String(), sections[j].String()) < 0 + return sections[i].String() < sections[j].String() }) } diff --git a/pkg/parse/parse.go b/pkg/parse/parse.go index e8532f8..34eb84e 100644 --- a/pkg/parse/parse.go +++ b/pkg/parse/parse.go @@ -22,11 +22,11 @@ func (l ImportList) Len() int { } func (l ImportList) Less(i, j int) bool { - if strings.Compare(l[i].Path, l[j].Path) == 0 { - return strings.Compare(l[i].Name, l[j].Name) < 0 + if l[i].Path == l[j].Path { + return l[i].Name < l[j].Name } - return strings.Compare(l[i].Path, l[j].Path) < 0 + return l[i].Path < l[j].Path } func (l ImportList) Swap(i, j int) { l[i], l[j] = l[j], l[i] }