github.com/vanstinator/golangci-lint@v0.0.0-20240223191551-cc572f00d9d1/pkg/golinters/wsl.go (about)

     1  package golinters
     2  
     3  import (
     4  	"github.com/bombsimon/wsl/v4"
     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 NewWSL(settings *config.WSLSettings) *goanalysis.Linter {
    12  	var conf *wsl.Configuration
    13  	if settings != nil {
    14  		conf = &wsl.Configuration{
    15  			StrictAppend:                     settings.StrictAppend,
    16  			AllowAssignAndCallCuddle:         settings.AllowAssignAndCallCuddle,
    17  			AllowAssignAndAnythingCuddle:     settings.AllowAssignAndAnythingCuddle,
    18  			AllowMultiLineAssignCuddle:       settings.AllowMultiLineAssignCuddle,
    19  			ForceCaseTrailingWhitespaceLimit: settings.ForceCaseTrailingWhitespaceLimit,
    20  			AllowTrailingComment:             settings.AllowTrailingComment,
    21  			AllowSeparatedLeadingComment:     settings.AllowSeparatedLeadingComment,
    22  			AllowCuddleDeclaration:           settings.AllowCuddleDeclaration,
    23  			AllowCuddleWithCalls:             settings.AllowCuddleWithCalls,
    24  			AllowCuddleWithRHS:               settings.AllowCuddleWithRHS,
    25  			ForceCuddleErrCheckAndAssign:     settings.ForceCuddleErrCheckAndAssign,
    26  			ErrorVariableNames:               settings.ErrorVariableNames,
    27  			ForceExclusiveShortDeclarations:  settings.ForceExclusiveShortDeclarations,
    28  		}
    29  	}
    30  
    31  	a := wsl.NewAnalyzer(conf)
    32  
    33  	return goanalysis.NewLinter(
    34  		a.Name,
    35  		a.Doc,
    36  		[]*analysis.Analyzer{a},
    37  		nil,
    38  	).WithLoadMode(goanalysis.LoadModeSyntax)
    39  }