2024-03-26 20:55:39 +01:00

40 lines
1.4 KiB
Go

package golinters
import (
"github.com/bombsimon/wsl/v4"
"golang.org/x/tools/go/analysis"
"github.com/golangci/golangci-lint/pkg/config"
"github.com/golangci/golangci-lint/pkg/goanalysis"
)
func NewWSL(settings *config.WSLSettings) *goanalysis.Linter {
var conf *wsl.Configuration
if settings != nil {
conf = &wsl.Configuration{
StrictAppend: settings.StrictAppend,
AllowAssignAndCallCuddle: settings.AllowAssignAndCallCuddle,
AllowAssignAndAnythingCuddle: settings.AllowAssignAndAnythingCuddle,
AllowMultiLineAssignCuddle: settings.AllowMultiLineAssignCuddle,
ForceCaseTrailingWhitespaceLimit: settings.ForceCaseTrailingWhitespaceLimit,
AllowTrailingComment: settings.AllowTrailingComment,
AllowSeparatedLeadingComment: settings.AllowSeparatedLeadingComment,
AllowCuddleDeclaration: settings.AllowCuddleDeclaration,
AllowCuddleWithCalls: settings.AllowCuddleWithCalls,
AllowCuddleWithRHS: settings.AllowCuddleWithRHS,
ForceCuddleErrCheckAndAssign: settings.ForceCuddleErrCheckAndAssign,
ErrorVariableNames: settings.ErrorVariableNames,
ForceExclusiveShortDeclarations: settings.ForceExclusiveShortDeclarations,
}
}
a := wsl.NewAnalyzer(conf)
return goanalysis.NewLinter(
a.Name,
a.Doc,
[]*analysis.Analyzer{a},
nil,
).WithLoadMode(goanalysis.LoadModeSyntax)
}