gci: improve error message (#3777)
This commit is contained in:
parent
52edd01248
commit
842abcde73
@ -2,7 +2,6 @@ package golinters
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"strings"
|
|
||||||
"sync"
|
"sync"
|
||||||
|
|
||||||
gcicfg "github.com/daixiang0/gci/pkg/config"
|
gcicfg "github.com/daixiang0/gci/pkg/config"
|
||||||
@ -145,7 +144,13 @@ func getErrorTextForGci(settings config.GciSettings) string {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if len(settings.Sections) > 0 {
|
if len(settings.Sections) > 0 {
|
||||||
text += " -s " + strings.Join(settings.Sections, ",")
|
for _, section := range settings.Sections {
|
||||||
|
text += " -s " + section
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if settings.CustomOrder {
|
||||||
|
text += " --custom-order"
|
||||||
}
|
}
|
||||||
|
|
||||||
return text
|
return text
|
||||||
|
3
test/testdata/configs/gci.yml
vendored
3
test/testdata/configs/gci.yml
vendored
@ -2,5 +2,6 @@ linters-settings:
|
|||||||
gci:
|
gci:
|
||||||
sections:
|
sections:
|
||||||
- standard
|
- standard
|
||||||
- prefix(github.com/golangci/golangci-lint)
|
- prefix(github.com/golangci/golangci-lint,github.com/daixiang0/gci)
|
||||||
- default
|
- default
|
||||||
|
custom-order: true
|
||||||
|
4
test/testdata/fix/in/gci.go
vendored
4
test/testdata/fix/in/gci.go
vendored
@ -6,11 +6,15 @@ package gci
|
|||||||
import (
|
import (
|
||||||
"github.com/golangci/golangci-lint/pkg/config"
|
"github.com/golangci/golangci-lint/pkg/config"
|
||||||
"golang.org/x/tools/go/analysis"
|
"golang.org/x/tools/go/analysis"
|
||||||
|
|
||||||
"fmt"
|
"fmt"
|
||||||
|
|
||||||
|
gcicfg "github.com/daixiang0/gci/pkg/config"
|
||||||
)
|
)
|
||||||
|
|
||||||
func GoimportsLocalTest() {
|
func GoimportsLocalTest() {
|
||||||
fmt.Print("x")
|
fmt.Print("x")
|
||||||
_ = config.Config{}
|
_ = config.Config{}
|
||||||
_ = analysis.Analyzer{}
|
_ = analysis.Analyzer{}
|
||||||
|
_ = gcicfg.BoolConfig{}
|
||||||
}
|
}
|
||||||
|
6
test/testdata/fix/out/gci.go
vendored
6
test/testdata/fix/out/gci.go
vendored
@ -6,13 +6,15 @@ package gci
|
|||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
|
||||||
"golang.org/x/tools/go/analysis"
|
gcicfg "github.com/daixiang0/gci/pkg/config"
|
||||||
|
|
||||||
"github.com/golangci/golangci-lint/pkg/config"
|
"github.com/golangci/golangci-lint/pkg/config"
|
||||||
|
|
||||||
|
"golang.org/x/tools/go/analysis"
|
||||||
)
|
)
|
||||||
|
|
||||||
func GoimportsLocalTest() {
|
func GoimportsLocalTest() {
|
||||||
fmt.Print("x")
|
fmt.Print("x")
|
||||||
_ = config.Config{}
|
_ = config.Config{}
|
||||||
_ = analysis.Analyzer{}
|
_ = analysis.Analyzer{}
|
||||||
|
_ = gcicfg.BoolConfig{}
|
||||||
}
|
}
|
||||||
|
11
test/testdata/gci.go
vendored
11
test/testdata/gci.go
vendored
@ -3,15 +3,16 @@
|
|||||||
package testdata
|
package testdata
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"golang.org/x/tools/go/analysis" // want "File is not \\`gci\\`-ed with --skip-generated -s standard -s prefix\\(github.com/golangci/golangci-lint,github.com/daixiang0/gci\\) -s default --custom-order"
|
||||||
|
"github.com/golangci/golangci-lint/pkg/config"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"errors"
|
||||||
"github.com/golangci/golangci-lint/pkg/config" // want "File is not \\`gci\\`-ed with --skip-generated -s standard,prefix\\(github.com/golangci/golangci-lint\\),default"
|
gcicfg "github.com/daixiang0/gci/pkg/config" // want "File is not \\`gci\\`-ed with --skip-generated -s standard -s prefix\\(github.com/golangci/golangci-lint,github.com/daixiang0/gci\\) -s default --custom-order"
|
||||||
|
|
||||||
"golang.org/x/tools/go/analysis" // want "File is not \\`gci\\`-ed with --skip-generated -s standard,prefix\\(github.com/golangci/golangci-lint\\),default"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
func GoimportsLocalTest() {
|
func GoimportsLocalTest() {
|
||||||
fmt.Print("x")
|
fmt.Print(errors.New("x"))
|
||||||
_ = config.Config{}
|
_ = config.Config{}
|
||||||
_ = analysis.Analyzer{}
|
_ = analysis.Analyzer{}
|
||||||
|
_ = gcicfg.BoolConfig{}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user