Skip to content

Commit b8f1e2a

Browse files
daixiang0ldez
andauthored
build(deps): bump github.com/daixiang0/gci from 0.3.4 to 0.4.0 (#2965)
Co-authored-by: Fernandez Ludovic <[email protected]>
1 parent 9317da6 commit b8f1e2a

File tree

5 files changed

+22
-44
lines changed

5 files changed

+22
-44
lines changed

.golangci.reference.yml

+3-14
Original file line numberDiff line numberDiff line change
@@ -341,28 +341,17 @@ linters-settings:
341341
# DEPRECATED: use `sections` and `prefix(github.com/org/project)` instead.
342342
local-prefixes: github.com/org/project
343343

344-
# Checks that no inline Comments are present.
345-
# Default: false
346-
no-inline-comments: true
347-
348-
# Checks that no prefix Comments(comment lines above an import) are present.
349-
# Default: false
350-
no-prefix-comments: true
351-
352344
# Section configuration to compare against.
353345
# Section names are case-insensitive and may contain parameters in ().
354346
# Default: ["standard", "default"]
355347
sections:
356348
- standard # Captures all standard packages if they do not match another section.
357349
- default # Contains all imports that could not be matched to another section type.
358-
- comment(your text here) # Prints the specified indented comment.
359-
- newLine # Prints an empty line
360350
- prefix(github.com/org/project) # Groups all imports with the specified Prefix.
361351

362-
# Separators that should be present between sections.
363-
# Default: ["newLine"]
364-
section-separators:
365-
- newLine
352+
# Skip generated files.
353+
# Default: true
354+
skip-generated: false
366355

367356
gocognit:
368357
# Minimal code complexity to report

go.mod

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ require (
2020
github.com/breml/errchkjson v0.3.0
2121
github.com/butuzov/ireturn v0.1.1
2222
github.com/charithe/durationcheck v0.0.9
23-
github.com/daixiang0/gci v0.3.4
23+
github.com/daixiang0/gci v0.4.0
2424
github.com/denis-tingaikin/go-header v0.4.3
2525
github.com/esimonov/ifshort v1.0.4
2626
github.com/fatih/color v1.13.0

go.sum

+3-2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pkg/config/linters_settings.go

+5-7
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,8 @@ var defaultLintersSettings = LintersSettings{
3131
ExcludeGodocExamples: true,
3232
},
3333
Gci: GciSettings{
34-
Sections: []string{"standard", "default"},
35-
SectionSeparator: []string{"newline"},
34+
Sections: []string{"standard", "default"},
35+
SkipGenerated: true,
3636
},
3737
Gocognit: GocognitSettings{
3838
MinComplexity: 30,
@@ -275,11 +275,9 @@ type FunlenSettings struct {
275275
}
276276

277277
type GciSettings struct {
278-
LocalPrefixes string `mapstructure:"local-prefixes"` // Deprecated
279-
NoInlineComments bool `mapstructure:"no-inline-comments"`
280-
NoPrefixComments bool `mapstructure:"no-prefix-comments"`
281-
Sections []string `mapstructure:"sections"`
282-
SectionSeparator []string `mapstructure:"section-separators"`
278+
LocalPrefixes string `mapstructure:"local-prefixes"` // Deprecated
279+
Sections []string `mapstructure:"sections"`
280+
SkipGenerated bool `mapstructure:"skip-generated"`
283281
}
284282

285283
type GocognitSettings struct {

pkg/golinters/gci.go

+10-20
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import (
55
"strings"
66
"sync"
77

8-
gcicfg "github.com/daixiang0/gci/pkg/configuration"
8+
gcicfg "github.com/daixiang0/gci/pkg/config"
99
"github.com/daixiang0/gci/pkg/gci"
1010
"github.com/pkg/errors"
1111
"golang.org/x/tools/go/analysis"
@@ -27,15 +27,13 @@ func NewGci(settings *config.GciSettings) *goanalysis.Linter {
2727
Run: goanalysis.DummyRun,
2828
}
2929

30-
var cfg *gci.GciConfiguration
30+
var cfg *gcicfg.Config
3131
if settings != nil {
32-
rawCfg := gci.GciStringConfiguration{
33-
Cfg: gcicfg.FormatterConfiguration{
34-
NoInlineComments: settings.NoInlineComments,
35-
NoPrefixComments: settings.NoPrefixComments,
32+
rawCfg := gcicfg.YamlConfig{
33+
Cfg: gcicfg.BoolConfig{
34+
SkipGenerated: settings.SkipGenerated,
3635
},
37-
SectionStrings: settings.Sections,
38-
SectionSeparatorStrings: settings.SectionSeparator,
36+
SectionStrings: settings.Sections,
3937
}
4038

4139
if settings.LocalPrefixes != "" {
@@ -75,7 +73,7 @@ func NewGci(settings *config.GciSettings) *goanalysis.Linter {
7573
}).WithLoadMode(goanalysis.LoadModeSyntax)
7674
}
7775

78-
func runGci(pass *analysis.Pass, lintCtx *linter.Context, cfg *gci.GciConfiguration, lock *sync.Mutex) ([]goanalysis.Issue, error) {
76+
func runGci(pass *analysis.Pass, lintCtx *linter.Context, cfg *gcicfg.Config, lock *sync.Mutex) ([]goanalysis.Issue, error) {
7977
var fileNames []string
8078
for _, f := range pass.Files {
8179
pos := pass.Fset.PositionFor(f.Pos(), false)
@@ -111,28 +109,20 @@ func runGci(pass *analysis.Pass, lintCtx *linter.Context, cfg *gci.GciConfigurat
111109
func getErrorTextForGci(settings config.GciSettings) string {
112110
text := "File is not `gci`-ed"
113111

114-
hasOptions := settings.NoInlineComments || settings.NoPrefixComments || len(settings.Sections) > 0 || len(settings.SectionSeparator) > 0
112+
hasOptions := settings.SkipGenerated || len(settings.Sections) > 0
115113
if !hasOptions {
116114
return text
117115
}
118116

119117
text += " with"
120118

121-
if settings.NoInlineComments {
122-
text += " -NoInlineComments"
123-
}
124-
125-
if settings.NoPrefixComments {
126-
text += " -NoPrefixComments"
119+
if settings.SkipGenerated {
120+
text += " -skip-generated"
127121
}
128122

129123
if len(settings.Sections) > 0 {
130124
text += " -s " + strings.Join(settings.Sections, ",")
131125
}
132126

133-
if len(settings.SectionSeparator) > 0 {
134-
text += " -x " + strings.Join(settings.SectionSeparator, ",")
135-
}
136-
137127
return text
138128
}

0 commit comments

Comments
 (0)