mirror of
https://github.com/woodpecker-ci/woodpecker.git
synced 2024-12-13 12:06:29 +00:00
56a854fe14
* update github.com/docker/cli * update github.com/docker/distribution * update github.com/docker/docker * update github.com/gin-gonic/gin * update github.com/golang-jwt/jwt/v4 * update github.com/golangci/golangci-lint * update github.com/gorilla/securecookie * update github.com/mattn/go-sqlite3 * update github.com/moby/moby * update github.com/prometheus/client_golang * update github.com/xanzy/go-gitlab
48 lines
1.5 KiB
Go
48 lines
1.5 KiB
Go
package golinters
|
|
|
|
import (
|
|
"fmt"
|
|
"strings"
|
|
|
|
gci "github.com/daixiang0/gci/pkg/analyzer"
|
|
"golang.org/x/tools/go/analysis"
|
|
|
|
"github.com/golangci/golangci-lint/pkg/config"
|
|
"github.com/golangci/golangci-lint/pkg/golinters/goanalysis"
|
|
"github.com/golangci/golangci-lint/pkg/lint/linter"
|
|
)
|
|
|
|
const gciName = "gci"
|
|
|
|
func NewGci(settings *config.GciSettings) *goanalysis.Linter {
|
|
var linterCfg map[string]map[string]interface{}
|
|
|
|
if settings != nil {
|
|
cfg := map[string]interface{}{
|
|
gci.NoInlineCommentsFlag: settings.NoInlineComments,
|
|
gci.NoPrefixCommentsFlag: settings.NoPrefixComments,
|
|
gci.SectionsFlag: strings.Join(settings.Sections, gci.SectionDelimiter),
|
|
gci.SectionSeparatorsFlag: strings.Join(settings.SectionSeparator, gci.SectionDelimiter),
|
|
}
|
|
|
|
if settings.LocalPrefixes != "" {
|
|
prefix := []string{"standard", "default", fmt.Sprintf("prefix(%s)", settings.LocalPrefixes)}
|
|
cfg[gci.SectionsFlag] = strings.Join(prefix, gci.SectionDelimiter)
|
|
}
|
|
|
|
linterCfg = map[string]map[string]interface{}{
|
|
gci.Analyzer.Name: cfg,
|
|
}
|
|
}
|
|
|
|
return goanalysis.NewLinter(
|
|
gciName,
|
|
"Gci controls golang package import order and makes it always deterministic.",
|
|
[]*analysis.Analyzer{gci.Analyzer},
|
|
linterCfg,
|
|
).WithContextSetter(func(lintCtx *linter.Context) {
|
|
if settings.LocalPrefixes != "" {
|
|
lintCtx.Log.Warnf("gci: `local-prefixes` is deprecated, use `sections` and `prefix(%s)` instead.", settings.LocalPrefixes)
|
|
}
|
|
}).WithLoadMode(goanalysis.LoadModeSyntax)
|
|
}
|