build(deps): bump github.com/daixiang0/gci from 0.3.4 to 0.4.0 (#2965)

Co-authored-by: Fernandez Ludovic <ldez@users.noreply.github.com>
This commit is contained in:
Loong Dai 2022-07-10 05:15:47 +08:00 committed by GitHub
parent 9317da6cf0
commit b8f1e2a549
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 22 additions and 44 deletions

View File

@ -341,28 +341,17 @@ linters-settings:
# DEPRECATED: use `sections` and `prefix(github.com/org/project)` instead.
local-prefixes: github.com/org/project
# Checks that no inline Comments are present.
# Default: false
no-inline-comments: true
# Checks that no prefix Comments(comment lines above an import) are present.
# Default: false
no-prefix-comments: true
# Section configuration to compare against.
# Section names are case-insensitive and may contain parameters in ().
# Default: ["standard", "default"]
sections:
- standard # Captures all standard packages if they do not match another section.
- default # Contains all imports that could not be matched to another section type.
- comment(your text here) # Prints the specified indented comment.
- newLine # Prints an empty line
- prefix(github.com/org/project) # Groups all imports with the specified Prefix.
# Separators that should be present between sections.
# Default: ["newLine"]
section-separators:
- newLine
# Skip generated files.
# Default: true
skip-generated: false
gocognit:
# Minimal code complexity to report

2
go.mod
View File

@ -20,7 +20,7 @@ require (
github.com/breml/errchkjson v0.3.0
github.com/butuzov/ireturn v0.1.1
github.com/charithe/durationcheck v0.0.9
github.com/daixiang0/gci v0.3.4
github.com/daixiang0/gci v0.4.0
github.com/denis-tingaikin/go-header v0.4.3
github.com/esimonov/ifshort v1.0.4
github.com/fatih/color v1.13.0

5
go.sum generated
View File

@ -129,8 +129,8 @@ github.com/cpuguy83/go-md2man/v2 v2.0.0/go.mod h1:maD7wRr/U5Z6m/iR4s+kqSMx2CaBsr
github.com/cpuguy83/go-md2man/v2 v2.0.2/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46tRHOmNcaadrF8o=
github.com/creack/pty v1.1.7/go.mod h1:lj5s0c3V2DBrqTV7llrYr5NG6My20zk30Fl46Y7DoTY=
github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E=
github.com/daixiang0/gci v0.3.4 h1:+EZ83znNs73C9ZBTM7xhNagMP6gJs5wlptiFiuce5BM=
github.com/daixiang0/gci v0.3.4/go.mod h1:pB1j339Q+2sv/EyKd4dgvGXcaBGIErim+dlhLDtqeW4=
github.com/daixiang0/gci v0.4.0 h1:WKWAjTsU05SQjDRpeyiJdYo4Jfh8nWpgctffJuqBXmc=
github.com/daixiang0/gci v0.4.0/go.mod h1:d0f+IJhr9loBtIq+ebwhRoTt1LGbPH96ih8bKlsRT9E=
github.com/davecgh/go-spew v0.0.0-20161028175848-04cdfd42973b/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
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=
@ -681,6 +681,7 @@ github.com/tetafro/godot v1.4.11 h1:BVoBIqAf/2QdbFmSwAWnaIqDivZdOV0ZRwEm6jivLKw=
github.com/tetafro/godot v1.4.11/go.mod h1:LR3CJpxDVGlYOWn3ZZg1PgNZdTUvzsZWu8xaEohUpn8=
github.com/timakin/bodyclose v0.0.0-20210704033933-f49887972144 h1:kl4KhGNsJIbDHS9/4U9yQo1UcPQM0kOMJHn29EoH/Ro=
github.com/timakin/bodyclose v0.0.0-20210704033933-f49887972144/go.mod h1:Qimiffbc6q9tBWlVV6x0P9sat/ao1xEkREYPPj9hphk=
github.com/tj/assert v0.0.3 h1:Df/BlaZ20mq6kuai7f5z2TvPFiwC3xaWJSDQNiIS3Rk=
github.com/tklauser/go-sysconf v0.3.10 h1:IJ1AZGZRWbY8T5Vfk04D9WOA5WSejdflXxP03OUqALw=
github.com/tklauser/go-sysconf v0.3.10/go.mod h1:C8XykCvCb+Gn0oNCWPIlcb0RuglQTYaQ2hGm7jmxEFk=
github.com/tklauser/numcpus v0.4.0 h1:E53Dm1HjH1/R2/aoCtXtPgzmElmn51aOkhCFSuZq//o=

View File

@ -31,8 +31,8 @@ var defaultLintersSettings = LintersSettings{
ExcludeGodocExamples: true,
},
Gci: GciSettings{
Sections: []string{"standard", "default"},
SectionSeparator: []string{"newline"},
Sections: []string{"standard", "default"},
SkipGenerated: true,
},
Gocognit: GocognitSettings{
MinComplexity: 30,
@ -275,11 +275,9 @@ type FunlenSettings struct {
}
type GciSettings struct {
LocalPrefixes string `mapstructure:"local-prefixes"` // Deprecated
NoInlineComments bool `mapstructure:"no-inline-comments"`
NoPrefixComments bool `mapstructure:"no-prefix-comments"`
Sections []string `mapstructure:"sections"`
SectionSeparator []string `mapstructure:"section-separators"`
LocalPrefixes string `mapstructure:"local-prefixes"` // Deprecated
Sections []string `mapstructure:"sections"`
SkipGenerated bool `mapstructure:"skip-generated"`
}
type GocognitSettings struct {

View File

@ -5,7 +5,7 @@ import (
"strings"
"sync"
gcicfg "github.com/daixiang0/gci/pkg/configuration"
gcicfg "github.com/daixiang0/gci/pkg/config"
"github.com/daixiang0/gci/pkg/gci"
"github.com/pkg/errors"
"golang.org/x/tools/go/analysis"
@ -27,15 +27,13 @@ func NewGci(settings *config.GciSettings) *goanalysis.Linter {
Run: goanalysis.DummyRun,
}
var cfg *gci.GciConfiguration
var cfg *gcicfg.Config
if settings != nil {
rawCfg := gci.GciStringConfiguration{
Cfg: gcicfg.FormatterConfiguration{
NoInlineComments: settings.NoInlineComments,
NoPrefixComments: settings.NoPrefixComments,
rawCfg := gcicfg.YamlConfig{
Cfg: gcicfg.BoolConfig{
SkipGenerated: settings.SkipGenerated,
},
SectionStrings: settings.Sections,
SectionSeparatorStrings: settings.SectionSeparator,
SectionStrings: settings.Sections,
}
if settings.LocalPrefixes != "" {
@ -75,7 +73,7 @@ func NewGci(settings *config.GciSettings) *goanalysis.Linter {
}).WithLoadMode(goanalysis.LoadModeSyntax)
}
func runGci(pass *analysis.Pass, lintCtx *linter.Context, cfg *gci.GciConfiguration, lock *sync.Mutex) ([]goanalysis.Issue, error) {
func runGci(pass *analysis.Pass, lintCtx *linter.Context, cfg *gcicfg.Config, lock *sync.Mutex) ([]goanalysis.Issue, error) {
var fileNames []string
for _, f := range pass.Files {
pos := pass.Fset.PositionFor(f.Pos(), false)
@ -111,28 +109,20 @@ func runGci(pass *analysis.Pass, lintCtx *linter.Context, cfg *gci.GciConfigurat
func getErrorTextForGci(settings config.GciSettings) string {
text := "File is not `gci`-ed"
hasOptions := settings.NoInlineComments || settings.NoPrefixComments || len(settings.Sections) > 0 || len(settings.SectionSeparator) > 0
hasOptions := settings.SkipGenerated || len(settings.Sections) > 0
if !hasOptions {
return text
}
text += " with"
if settings.NoInlineComments {
text += " -NoInlineComments"
}
if settings.NoPrefixComments {
text += " -NoPrefixComments"
if settings.SkipGenerated {
text += " -skip-generated"
}
if len(settings.Sections) > 0 {
text += " -s " + strings.Join(settings.Sections, ",")
}
if len(settings.SectionSeparator) > 0 {
text += " -x " + strings.Join(settings.SectionSeparator, ",")
}
return text
}