Skip to content

Commit f939c27

Browse files
committed
feat: allow to disable typecheck on internal tests
1 parent a165b7c commit f939c27

File tree

4 files changed

+9
-4
lines changed

4 files changed

+9
-4
lines changed

pkg/lint/lintersdb/enabled_set.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ func NewEnabledSet(m *Manager, v *Validator, log logutils.Log, cfg *config.Confi
3131
}
3232
}
3333

34+
//nolint:gocyclo // the complexity cannot be reduced.
3435
func (es EnabledSet) build(lcfg *config.Linters, enabledByDefaultLinters []*linter.Config) map[string]*linter.Config {
3536
es.debugf("Linters config: %#v", lcfg)
3637

@@ -80,7 +81,7 @@ func (es EnabledSet) build(lcfg *config.Linters, enabledByDefaultLinters []*lint
8081
}
8182

8283
// typecheck is not a real linter and cannot be disabled.
83-
if _, ok := resultLintersSet["typecheck"]; !ok {
84+
if _, ok := resultLintersSet["typecheck"]; !ok && !es.cfg.InternalCmdTest {
8485
for _, lc := range es.m.GetLinterConfigs("typecheck") {
8586
// it's important to use lc.Name() nor name because name can be alias
8687
resultLintersSet[lc.Name()] = lc

test/run_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -243,7 +243,7 @@ func TestLineDirective(t *testing.T) {
243243
},
244244
configPath: "testdata/linedirective/gomodguard.yml",
245245
targetPath: "linedirective",
246-
expected: "import of package `github.com/ryancurrah/gomodguard` is blocked because the module is not " +
246+
expected: "import of package `golang.org/x/tools/go/analysis` is blocked because the module is not " +
247247
"in the allowed modules list. (gomodguard)",
248248
},
249249
{

test/testdata/linedirective/gomodguard.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@ linters-settings:
22
gomodguard:
33
allowed:
44
domains:
5-
- golang.org
5+
- github.com

test/testdata/linedirective/hello.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
package main
44

55
import (
6-
"github.com/ryancurrah/gomodguard"
6+
"golang.org/x/tools/go/analysis"
77
)
88

99
func _() {
@@ -26,6 +26,10 @@ func b() {
2626
fmt.Println("foo")
2727
}
2828

29+
func c(){
30+
_ = analysis.Analyzer{}
31+
}
32+
2933
func wsl() bool {
3034

3135
return true

0 commit comments

Comments
 (0)