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

     1  package golinters
     2  
     3  import (
     4  	"golang.org/x/tools/go/analysis"
     5  	scconfig "honnef.co/go/tools/config"
     6  	"honnef.co/go/tools/stylecheck"
     7  
     8  	"github.com/elek/golangci-lint/pkg/config"
     9  	"github.com/elek/golangci-lint/pkg/golinters/goanalysis"
    10  )
    11  
    12  func NewStylecheck(settings *config.StaticCheckSettings) *goanalysis.Linter {
    13  	cfg := staticCheckConfig(settings)
    14  
    15  	// `scconfig.Analyzer` is a singleton, then it's not possible to have more than one instance for all staticcheck "sub-linters".
    16  	// When we will merge the 4 "sub-linters", the problem will disappear: https://github.com/golangci/golangci-lint/issues/357
    17  	// Currently only stylecheck analyzer has a configuration in staticcheck.
    18  	scconfig.Analyzer.Run = func(pass *analysis.Pass) (interface{}, error) {
    19  		return cfg, nil
    20  	}
    21  
    22  	analyzers := setupStaticCheckAnalyzers(stylecheck.Analyzers, getGoVersion(settings), cfg.Checks)
    23  
    24  	return goanalysis.NewLinter(
    25  		"stylecheck",
    26  		"Stylecheck is a replacement for golint",
    27  		analyzers,
    28  		nil,
    29  	).WithLoadMode(goanalysis.LoadModeTypesInfo)
    30  }