Skip to content

Commit 353dc75

Browse files
committed
build(deps): bump github.com/bombsimon/wsl/v4 from 3.4.0 to 4.1.0
1 parent 4384969 commit 353dc75

File tree

4 files changed

+26
-88
lines changed

4 files changed

+26
-88
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.1.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-73
Original file line numberDiff line numberDiff line change
@@ -1,89 +1,38 @@
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
38-
}
39-
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-
},
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+
}
5629
}
5730

31+
a := wsl.NewAnalyzer(conf)
5832
return goanalysis.NewLinter(
59-
wslName,
60-
"Whitespace Linter - Forces you to use empty lines!",
61-
[]*analysis.Analyzer{analyzer},
33+
a.Name,
34+
a.Doc,
35+
[]*analysis.Analyzer{a},
6236
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
37+
).WithLoadMode(goanalysis.LoadModeSyntax)
8938
}

test/run_test.go

-10
Original file line numberDiff line numberDiff line change
@@ -266,16 +266,6 @@ func TestLineDirective(t *testing.T) {
266266
targetPath: "linedirective",
267267
expected: "is a misspelling of `language` (misspell)",
268268
},
269-
{
270-
desc: "wsl",
271-
args: []string{
272-
"-Ewsl",
273-
"--disable-all",
274-
},
275-
configPath: "",
276-
targetPath: "linedirective",
277-
expected: "block should not start with a whitespace (wsl)",
278-
},
279269
}
280270

281271
for _, test := range testCases {

0 commit comments

Comments
 (0)