-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
/
Copy pathwsl.go
41 lines (36 loc) · 1.59 KB
/
wsl.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
package wsl
import (
"github.com/bombsimon/wsl/v4"
"golang.org/x/tools/go/analysis"
"github.com/golangci/golangci-lint/v2/pkg/config"
"github.com/golangci/golangci-lint/v2/pkg/goanalysis"
)
func New(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,
AllowCuddleUsedInBlock: settings.AllowCuddleUsedInBlock,
ErrorVariableNames: settings.ErrorVariableNames,
ForceExclusiveShortDeclarations: settings.ForceExclusiveShortDeclarations,
IncludeGenerated: true, // force to true because golangci-lint already have a way to filter generated files.
}
}
a := wsl.NewAnalyzer(conf)
return goanalysis.NewLinter(
a.Name,
a.Doc,
[]*analysis.Analyzer{a},
nil,
).WithLoadMode(goanalysis.LoadModeSyntax)
}