From 726b8153cac6c04238264b189f5b05ec059f9330 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 4 Sep 2024 04:30:49 +0200 Subject: [PATCH] build(deps): bump github.com/daixiang0/gci from 0.13.4 to 0.13.5 (#4975) Co-authored-by: Fernandez Ludovic --- .golangci.next.reference.yml | 4 ++++ go.mod | 2 +- go.sum | 4 ++-- jsonschema/golangci.next.jsonschema.json | 5 +++++ pkg/config/linters_settings.go | 1 + pkg/golinters/gci/gci.go | 10 ++++++---- 6 files changed, 19 insertions(+), 7 deletions(-) diff --git a/.golangci.next.reference.yml b/.golangci.next.reference.yml index e08464bdd6b8..4e33e3cc08a4 100644 --- a/.golangci.next.reference.yml +++ b/.golangci.next.reference.yml @@ -464,6 +464,10 @@ linters-settings: # Default: false custom-order: true + # Drops lexical ordering for custom sections. + # Default: false + no-lex-order: true + ginkgolinter: # Suppress the wrong length assertion warning. # Default: false diff --git a/go.mod b/go.mod index 5041acac4448..ba1cacd23569 100644 --- a/go.mod +++ b/go.mod @@ -32,7 +32,7 @@ require ( github.com/charithe/durationcheck v0.0.10 github.com/ckaznocha/intrange v0.1.2 github.com/curioswitch/go-reassign v0.2.0 - github.com/daixiang0/gci v0.13.4 + github.com/daixiang0/gci v0.13.5 github.com/denis-tingaikin/go-header v0.5.0 github.com/fatih/color v1.17.0 github.com/firefart/nonamedreturns v1.0.5 diff --git a/go.sum b/go.sum index 4098d859c85e..fead56b68bae 100644 --- a/go.sum +++ b/go.sum @@ -122,8 +122,8 @@ github.com/cncf/udpa/go v0.0.0-20191209042840-269d4d468f6f/go.mod h1:M8M6+tZqaGX github.com/cpuguy83/go-md2man/v2 v2.0.4/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46tRHOmNcaadrF8o= github.com/curioswitch/go-reassign v0.2.0 h1:G9UZyOcpk/d7Gd6mqYgd8XYWFMw/znxwGDUstnC9DIo= github.com/curioswitch/go-reassign v0.2.0/go.mod h1:x6OpXuWvgfQaMGks2BZybTngWjT84hqJfKoO8Tt/Roc= -github.com/daixiang0/gci v0.13.4 h1:61UGkmpoAcxHM2hhNkZEf5SzwQtWJXTSws7jaPyqwlw= -github.com/daixiang0/gci v0.13.4/go.mod h1:12etP2OniiIdP4q+kjUGrC/rUagga7ODbqsom5Eo5Yk= +github.com/daixiang0/gci v0.13.5 h1:kThgmH1yBmZSBCh1EJVxQ7JsHpm5Oms0AMed/0LaH4c= +github.com/daixiang0/gci v0.13.5/go.mod h1:12etP2OniiIdP4q+kjUGrC/rUagga7ODbqsom5Eo5Yk= github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= diff --git a/jsonschema/golangci.next.jsonschema.json b/jsonschema/golangci.next.jsonschema.json index f8233a77759d..b14b572de681 100644 --- a/jsonschema/golangci.next.jsonschema.json +++ b/jsonschema/golangci.next.jsonschema.json @@ -1103,6 +1103,11 @@ "description": "Enable custom order of sections.", "type": "boolean", "default": false + }, + "no-lex-order": { + "description": "Drops lexical ordering for custom sections.", + "type": "boolean", + "default": false } } }, diff --git a/pkg/config/linters_settings.go b/pkg/config/linters_settings.go index 267efe2cf6e7..7bd45e1849ad 100644 --- a/pkg/config/linters_settings.go +++ b/pkg/config/linters_settings.go @@ -465,6 +465,7 @@ type GciSettings struct { Sections []string `mapstructure:"sections"` SkipGenerated bool `mapstructure:"skip-generated"` CustomOrder bool `mapstructure:"custom-order"` + NoLexOrder bool `mapstructure:"no-lex-order"` // Deprecated: use Sections instead. LocalPrefixes string `mapstructure:"local-prefixes"` diff --git a/pkg/golinters/gci/gci.go b/pkg/golinters/gci/gci.go index 38ed2a033067..a9afb6c89312 100644 --- a/pkg/golinters/gci/gci.go +++ b/pkg/golinters/gci/gci.go @@ -44,6 +44,7 @@ func New(settings *config.GciSettings) *goanalysis.Linter { Cfg: gcicfg.BoolConfig{ SkipGenerated: settings.SkipGenerated, CustomOrder: settings.CustomOrder, + NoLexOrder: settings.NoLexOrder, }, SectionStrings: settings.Sections, } @@ -195,7 +196,7 @@ func diffFormattedFilesToArray(paths []string, cfg gcicfg.Config, diffs *[]strin } // Code below this comment is borrowed and modified from gci. -// https://github.com/daixiang0/gci/blob/4725b0c101801e7449530eee2ddb0c72592e3405/pkg/config/config.go +// https://github.com/daixiang0/gci/blob/v0.13.5/pkg/config/config.go var defaultOrder = map[string]int{ section.StandardType: 0, @@ -229,10 +230,11 @@ func (g YamlConfig) Parse() (*gcicfg.Config, error) { sort.Slice(sections, func(i, j int) bool { sectionI, sectionJ := sections[i].Type(), sections[j].Type() - if strings.Compare(sectionI, sectionJ) == 0 { - return strings.Compare(sections[i].String(), sections[j].String()) < 0 + if g.origin.Cfg.NoLexOrder || strings.Compare(sectionI, sectionJ) != 0 { + return defaultOrder[sectionI] < defaultOrder[sectionJ] } - return defaultOrder[sectionI] < defaultOrder[sectionJ] + + return strings.Compare(sections[i].String(), sections[j].String()) < 0 }) }