github.com/elek/golangci-lint@v1.42.2-0.20211208090441-c05b7fcb3a9a/pkg/golinters/wrapcheck.go (about)

     1  package golinters
     2  
     3  import (
     4  	"github.com/tomarrell/wrapcheck/v2/wrapcheck"
     5  	"golang.org/x/tools/go/analysis"
     6  
     7  	"github.com/elek/golangci-lint/pkg/config"
     8  	"github.com/elek/golangci-lint/pkg/golinters/goanalysis"
     9  )
    10  
    11  const wrapcheckName = "wrapcheck"
    12  
    13  func NewWrapcheck(settings *config.WrapcheckSettings) *goanalysis.Linter {
    14  	cfg := wrapcheck.NewDefaultConfig()
    15  	if settings != nil {
    16  		if len(settings.IgnoreSigs) != 0 {
    17  			cfg.IgnoreSigs = settings.IgnoreSigs
    18  		}
    19  		if len(settings.IgnorePackageGlobs) != 0 {
    20  			cfg.IgnorePackageGlobs = settings.IgnorePackageGlobs
    21  		}
    22  	}
    23  
    24  	a := wrapcheck.NewAnalyzer(cfg)
    25  
    26  	return goanalysis.NewLinter(
    27  		wrapcheckName,
    28  		a.Doc,
    29  		[]*analysis.Analyzer{a},
    30  		nil,
    31  	).WithLoadMode(goanalysis.LoadModeTypesInfo)
    32  }