github.com/vanstinator/golangci-lint@v0.0.0-20240223191551-cc572f00d9d1/pkg/golinters/nlreturn.go (about) 1 package golinters 2 3 import ( 4 "github.com/ssgreg/nlreturn/v2/pkg/nlreturn" 5 "golang.org/x/tools/go/analysis" 6 7 "github.com/vanstinator/golangci-lint/pkg/config" 8 "github.com/vanstinator/golangci-lint/pkg/golinters/goanalysis" 9 ) 10 11 func NewNLReturn(settings *config.NlreturnSettings) *goanalysis.Linter { 12 a := nlreturn.NewAnalyzer() 13 14 cfg := map[string]map[string]any{} 15 if settings != nil { 16 cfg[a.Name] = map[string]any{ 17 "block-size": settings.BlockSize, 18 } 19 } 20 21 return goanalysis.NewLinter( 22 a.Name, 23 "nlreturn checks for a new line before return and branch statements to increase code clarity", 24 []*analysis.Analyzer{a}, 25 cfg, 26 ).WithLoadMode(goanalysis.LoadModeSyntax) 27 }