Skip to content

Commit e32f2f3

Browse files
alexandearldezbombsimon
authored
build(deps): bump github.com/bombsimon/wsl/v4 from 3.4.0 to 4.2.0 (#4215)
Co-authored-by: Fernandez Ludovic <ldez@users.noreply.github.com> Co-authored-by: Simon Sawert <simon@sawert.se>
1 parent f269abe commit e32f2f3

File tree

3 files changed

+26
-77
lines changed

3 files changed

+26
-77
lines changed

go.mod

+1-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ require (
2222
github.com/ashanbrown/makezero v1.1.1
2323
github.com/bkielbasa/cyclop v1.2.1
2424
github.com/blizzy78/varnamelen v0.8.0
25-
github.com/bombsimon/wsl/v3 v3.4.0
25+
github.com/bombsimon/wsl/v4 v4.2.0
2626
github.com/breml/bidichk v0.2.7
2727
github.com/breml/errchkjson v0.3.6
2828
github.com/butuzov/ireturn v0.2.2

go.sum

+3-4
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pkg/golinters/wsl.go

+22-72
Original file line numberDiff line numberDiff line change
@@ -1,89 +1,39 @@
11
package golinters
22

33
import (
4-
"sync"
5-
6-
"github.com/bombsimon/wsl/v3"
4+
"github.com/bombsimon/wsl/v4"
75
"golang.org/x/tools/go/analysis"
86

97
"github.com/golangci/golangci-lint/pkg/config"
108
"github.com/golangci/golangci-lint/pkg/golinters/goanalysis"
11-
"github.com/golangci/golangci-lint/pkg/lint/linter"
12-
"github.com/golangci/golangci-lint/pkg/result"
139
)
1410

15-
const wslName = "wsl"
16-
17-
// NewWSL returns a new WSL linter.
1811
func NewWSL(settings *config.WSLSettings) *goanalysis.Linter {
19-
var mu sync.Mutex
20-
var resIssues []goanalysis.Issue
21-
22-
conf := wsl.DefaultConfig()
23-
12+
var conf *wsl.Configuration
2413
if settings != nil {
25-
conf.StrictAppend = settings.StrictAppend
26-
conf.AllowAssignAndCallCuddle = settings.AllowAssignAndCallCuddle
27-
conf.AllowAssignAndAnythingCuddle = settings.AllowAssignAndAnythingCuddle
28-
conf.AllowMultiLineAssignCuddle = settings.AllowMultiLineAssignCuddle
29-
conf.ForceCaseTrailingWhitespaceLimit = settings.ForceCaseTrailingWhitespaceLimit
30-
conf.AllowTrailingComment = settings.AllowTrailingComment
31-
conf.AllowSeparatedLeadingComment = settings.AllowSeparatedLeadingComment
32-
conf.AllowCuddleDeclaration = settings.AllowCuddleDeclaration
33-
conf.AllowCuddleWithCalls = settings.AllowCuddleWithCalls
34-
conf.AllowCuddleWithRHS = settings.AllowCuddleWithRHS
35-
conf.ForceCuddleErrCheckAndAssign = settings.ForceCuddleErrCheckAndAssign
36-
conf.ErrorVariableNames = settings.ErrorVariableNames
37-
conf.ForceExclusiveShortDeclarations = settings.ForceExclusiveShortDeclarations
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+
}
3829
}
3930

40-
analyzer := &analysis.Analyzer{
41-
Name: goanalysis.TheOnlyAnalyzerName,
42-
Doc: goanalysis.TheOnlyanalyzerDoc,
43-
Run: func(pass *analysis.Pass) (any, error) {
44-
issues := runWSL(pass, &conf)
45-
46-
if len(issues) == 0 {
47-
return nil, nil
48-
}
49-
50-
mu.Lock()
51-
resIssues = append(resIssues, issues...)
52-
mu.Unlock()
53-
54-
return nil, nil
55-
},
56-
}
31+
a := wsl.NewAnalyzer(conf)
5732

5833
return goanalysis.NewLinter(
59-
wslName,
60-
"Whitespace Linter - Forces you to use empty lines!",
61-
[]*analysis.Analyzer{analyzer},
34+
a.Name,
35+
a.Doc,
36+
[]*analysis.Analyzer{a},
6237
nil,
63-
).WithIssuesReporter(func(*linter.Context) []goanalysis.Issue {
64-
return resIssues
65-
}).WithLoadMode(goanalysis.LoadModeSyntax)
66-
}
67-
68-
func runWSL(pass *analysis.Pass, conf *wsl.Configuration) []goanalysis.Issue {
69-
if conf == nil {
70-
return nil
71-
}
72-
73-
files := getFileNames(pass)
74-
wslErrors, _ := wsl.NewProcessorWithConfig(*conf).ProcessFiles(files)
75-
if len(wslErrors) == 0 {
76-
return nil
77-
}
78-
79-
var issues []goanalysis.Issue
80-
for _, err := range wslErrors {
81-
issues = append(issues, goanalysis.NewIssue(&result.Issue{
82-
FromLinter: wslName,
83-
Pos: err.Position,
84-
Text: err.Reason,
85-
}, pass))
86-
}
87-
88-
return issues
38+
).WithLoadMode(goanalysis.LoadModeSyntax)
8939
}

0 commit comments

Comments
 (0)