|
| 1 | +package godoclint |
| 2 | + |
| 3 | +import ( |
| 4 | + glcompose "github.com/godoc-lint/godoc-lint/pkg/compose" |
| 5 | + glconfig "github.com/godoc-lint/godoc-lint/pkg/config" |
| 6 | + |
| 7 | + "github.com/golangci/golangci-lint/v2/pkg/config" |
| 8 | + "github.com/golangci/golangci-lint/v2/pkg/goanalysis" |
| 9 | +) |
| 10 | + |
| 11 | +func New(settings *config.GodoclintSettings) *goanalysis.Linter { |
| 12 | + pcfg := glconfig.PlainConfig{ |
| 13 | + Include: settings.Include, |
| 14 | + Exclude: settings.Exclude, |
| 15 | + Enable: settings.Enable, |
| 16 | + Disable: settings.Disable, |
| 17 | + } |
| 18 | + |
| 19 | + if settings.Options != nil { |
| 20 | + pcfg.Options = &glconfig.PlainRuleOptions{ |
| 21 | + MaxLenLength: settings.Options.MaxLenLength, |
| 22 | + MaxLenIncludeTests: settings.Options.MaxLenIncludeTests, |
| 23 | + PkgDocStartWith: settings.Options.PkgDocStartWith, |
| 24 | + PkgDocIncludeTests: settings.Options.PkgDocIncludeTests, |
| 25 | + SinglePkgDocIncludeTests: settings.Options.SinglePkgDocIncludeTests, |
| 26 | + RequirePkgDocIncludeTests: settings.Options.RequirePkgDocIncludeTests, |
| 27 | + RequireDocIncludeTests: settings.Options.RequireDocIncludeTests, |
| 28 | + RequireDocIgnoreExported: settings.Options.RequireDocIgnoreExported, |
| 29 | + RequireDocIgnoreUnexported: settings.Options.RequireDocIgnoreUnexported, |
| 30 | + StartWithNamePattern: settings.Options.StartWithNamePattern, |
| 31 | + StartWithNameIncludeTests: settings.Options.StartWithNameIncludeTests, |
| 32 | + NoUnusedLinkIncludeTests: settings.Options.NoUnusedLinkIncludeTests, |
| 33 | + } |
| 34 | + } |
| 35 | + |
| 36 | + composition := glcompose.Compose(glcompose.CompositionConfig{ |
| 37 | + BaseDirPlainConfig: &pcfg, |
| 38 | + }) |
| 39 | + |
| 40 | + return goanalysis. |
| 41 | + NewLinterFromAnalyzer(composition.Analyzer.GetAnalyzer()). |
| 42 | + WithLoadMode(goanalysis.LoadModeTypesInfo) |
| 43 | +} |
0 commit comments