Skip to content

Commit 809be02

Browse files
authored
fix: linters load mode (#1862)
1 parent 8db518c commit 809be02

File tree

7 files changed

+23
-18
lines changed

7 files changed

+23
-18
lines changed

pkg/golinters/forcetypeassert.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,5 +15,5 @@ func NewForceTypeAssert() *goanalysis.Linter {
1515
"finds forced type assertions",
1616
[]*analysis.Analyzer{a},
1717
nil,
18-
).WithLoadMode(goanalysis.LoadModeTypesInfo)
18+
).WithLoadMode(goanalysis.LoadModeSyntax)
1919
}

pkg/golinters/ineffassign.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,5 +13,5 @@ func NewIneffassign() *goanalysis.Linter {
1313
"Detects when assignments to existing variables are not used",
1414
[]*analysis.Analyzer{ineffassign.Analyzer},
1515
nil,
16-
).WithLoadMode(goanalysis.LoadModeTypesInfo)
16+
).WithLoadMode(goanalysis.LoadModeSyntax)
1717
}

pkg/golinters/makezero.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,5 +56,5 @@ func NewMakezero() *goanalysis.Linter {
5656
}
5757
}).WithIssuesReporter(func(*linter.Context) []goanalysis.Issue {
5858
return resIssues
59-
}).WithLoadMode(goanalysis.LoadModeSyntax | goanalysis.LoadModeTypesInfo)
59+
}).WithLoadMode(goanalysis.LoadModeTypesInfo)
6060
}

pkg/golinters/paralleltest.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,5 +17,5 @@ func NewParallelTest() *goanalysis.Linter {
1717
"paralleltest detects missing usage of t.Parallel() method in your Go test",
1818
analyzers,
1919
nil,
20-
).WithLoadMode(goanalysis.LoadModeTypesInfo)
20+
).WithLoadMode(goanalysis.LoadModeSyntax)
2121
}

pkg/golinters/unused.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ func NewUnused() *goanalysis.Linter {
5959
nil,
6060
).WithIssuesReporter(func(lintCtx *linter.Context) []goanalysis.Issue {
6161
return resIssues
62-
}).WithLoadMode(goanalysis.LoadModeSyntax | goanalysis.LoadModeTypesInfo)
62+
}).WithLoadMode(goanalysis.LoadModeTypesInfo)
6363

6464
return lnt
6565
}

pkg/lint/lintersdb/manager.go

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -218,15 +218,14 @@ func (m Manager) GetAllSupportedLinterConfigs() []*linter.Config {
218218
WithURL("https://github.com/mdempsky/unconvert"),
219219
linter.NewConfig(golinters.NewIneffassign()).
220220
WithSince("v1.0.0").
221-
WithLoadForGoAnalysis().
222221
WithPresets(linter.PresetUnused).
223222
WithURL("https://github.com/gordonklaus/ineffassign"),
224223
linter.NewConfig(golinters.NewDupl()).
225224
WithSince("v1.0.0").
226225
WithPresets(linter.PresetStyle).
227226
WithURL("https://github.com/mibk/dupl"),
228227
linter.NewConfig(golinters.NewGoconst()).
229-
WithSince("").
228+
WithSince("v1.0.0").
230229
WithPresets(linter.PresetStyle).
231230
WithURL("https://github.com/jgautheron/goconst"),
232231
linter.NewConfig(golinters.NewDeadcode()).
@@ -255,7 +254,6 @@ func (m Manager) GetAllSupportedLinterConfigs() []*linter.Config {
255254
linter.NewConfig(golinters.NewAsciicheck()).
256255
WithSince("v1.26.0").
257256
WithPresets(linter.PresetBugs, linter.PresetStyle).
258-
WithLoadForGoAnalysis().
259257
WithURL("https://github.com/tdakkota/asciicheck"),
260258

261259
linter.NewConfig(golinters.NewGofmt()).
@@ -276,12 +274,10 @@ func (m Manager) GetAllSupportedLinterConfigs() []*linter.Config {
276274
linter.NewConfig(golinters.NewGoHeader()).
277275
WithSince("v1.28.0").
278276
WithPresets(linter.PresetStyle).
279-
WithLoadForGoAnalysis().
280277
WithURL("https://github.com/denis-tingajkin/go-header"),
281278
linter.NewConfig(golinters.NewGci()).
282279
WithSince("v1.30.0").
283280
WithPresets(linter.PresetFormatting, linter.PresetImport).
284-
WithLoadForGoAnalysis().
285281
WithAutoFix().
286282
WithURL("https://github.com/daixiang0/gci"),
287283
linter.NewConfig(golinters.NewMaligned()).
@@ -371,7 +367,6 @@ func (m Manager) GetAllSupportedLinterConfigs() []*linter.Config {
371367
linter.NewConfig(golinters.NewGomodguard()).
372368
WithSince("v1.25.0").
373369
WithPresets(linter.PresetStyle, linter.PresetImport, linter.PresetModule).
374-
WithLoadForGoAnalysis().
375370
WithURL("https://github.com/ryancurrah/gomodguard"),
376371
linter.NewConfig(golinters.NewGodot()).
377372
WithSince("v1.25.0").
@@ -381,7 +376,6 @@ func (m Manager) GetAllSupportedLinterConfigs() []*linter.Config {
381376
linter.NewConfig(golinters.NewTestpackage(testpackageCfg)).
382377
WithSince("v1.25.0").
383378
WithPresets(linter.PresetStyle, linter.PresetTest).
384-
WithLoadForGoAnalysis().
385379
WithURL("https://github.com/maratori/testpackage"),
386380
linter.NewConfig(golinters.NewNestif()).
387381
WithSince("v1.25.0").
@@ -405,7 +399,6 @@ func (m Manager) GetAllSupportedLinterConfigs() []*linter.Config {
405399
linter.NewConfig(golinters.NewNLReturn()).
406400
WithSince("v1.30.0").
407401
WithPresets(linter.PresetStyle).
408-
WithLoadForGoAnalysis().
409402
WithURL("https://github.com/ssgreg/nlreturn"),
410403
linter.NewConfig(golinters.NewWrapcheck()).
411404
WithSince("v1.32.0").
@@ -435,7 +428,6 @@ func (m Manager) GetAllSupportedLinterConfigs() []*linter.Config {
435428
linter.NewConfig(golinters.NewParallelTest()).
436429
WithSince("v1.33.0").
437430
WithPresets(linter.PresetStyle, linter.PresetTest).
438-
WithLoadForGoAnalysis().
439431
WithURL("https://github.com/kunwardeep/paralleltest"),
440432
linter.NewConfig(golinters.NewMakezero()).
441433
WithSince("v1.34.0").
@@ -482,12 +474,10 @@ func (m Manager) GetAllSupportedLinterConfigs() []*linter.Config {
482474
linter.NewConfig(golinters.NewForceTypeAssert()).
483475
WithSince("v1.38.0").
484476
WithPresets(linter.PresetStyle).
485-
WithLoadForGoAnalysis().
486477
WithURL("https://github.com/gostaticanalysis/forcetypeassert"),
487478
linter.NewConfig(golinters.NewGoModDirectives(goModDirectivesCfg)).
488479
WithSince("v1.39.0").
489480
WithPresets(linter.PresetStyle, linter.PresetModule).
490-
WithLoadForGoAnalysis().
491481
WithURL("https://github.com/ldez/gomoddirectives"),
492482

493483
// nolintlint must be last because it looks at the results of all the previous linters for unused nolint directives

test/testdata/asciicheck.go

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,23 @@
11
//args: -Easciicheck
22
package testdata
33

4-
import "time"
4+
import (
5+
"fmt"
6+
"time"
7+
)
58

6-
type TеstStruct struct { // ERROR `identifier "TеstStruct" contain non-ASCII character: U\+0435 'е'`
9+
type AsciicheckTеstStruct struct { // ERROR `identifier "AsciicheckTеstStruct" contain non-ASCII character: U\+0435 'е'`
710
Date time.Time
811
}
12+
13+
type AsciicheckField struct{}
14+
15+
type AsciicheckJustStruct struct {
16+
Tеst AsciicheckField // ERROR `identifier "Tеst" contain non-ASCII character: U\+0435 'е'`
17+
}
18+
19+
func AsciicheckTеstFunc() { // ERROR `identifier "AsciicheckTеstFunc" contain non-ASCII character: U\+0435 'е'`
20+
var tеstVar int // ERROR `identifier "tеstVar" contain non-ASCII character: U\+0435 'е'`
21+
tеstVar = 0
22+
fmt.Println(tеstVar)
23+
}

0 commit comments

Comments
 (0)