Skip to content

Commit

Permalink
build(deps): bump github.com/daixiang0/gci from 0.13.4 to 0.13.5 (#4975)
Browse files Browse the repository at this point in the history
Co-authored-by: Fernandez Ludovic <[email protected]>
  • Loading branch information
dependabot[bot] and ldez authored Sep 4, 2024
1 parent 54d089d commit 726b815
Show file tree
Hide file tree
Showing 6 changed files with 19 additions and 7 deletions.
4 changes: 4 additions & 0 deletions .golangci.next.reference.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions go.sum

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions jsonschema/golangci.next.jsonschema.json
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
}
},
Expand Down
1 change: 1 addition & 0 deletions pkg/config/linters_settings.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"`
Expand Down
10 changes: 6 additions & 4 deletions pkg/golinters/gci/gci.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
}
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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
})
}

Expand Down

0 comments on commit 726b815

Please sign in to comment.