Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions pkg/lint/runner.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,15 @@ func NewRunner(log logutils.Log, cfg *config.Config, goenv *goutil.Env,
}
}

switch len(enabledLinters) {
case 0:
return nil, errors.New("no linters enabled")
case 1:
if _, ok := enabledLinters["typecheck"]; ok {
return nil, errors.New("no linters enabled")
}
}

formattersCfg := &config.Formatters{
Enable: enabledFormatters,
Settings: cfg.Linters.Settings.FormatterSettings,
Expand Down
18 changes: 18 additions & 0 deletions test/run_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,24 @@ func TestNotExistingDirRun(t *testing.T) {
ExpectOutputContains(testshared.NormalizeFileInString("/testdata/no_such_dir"))
}

func TestNoLintersEnabled(t *testing.T) {
cfg := `
version: "2"
linters:
default: none
enable: []
`

testshared.NewRunnerBuilder(t).
WithConfig(cfg).
WithArgs("--show-stats=false").
WithTargetPath(testdataDir, "autogenerated").
Runner().
Install().
Run().
ExpectOutputContains("Running error: no linters enabled")
}

func TestSymlinkLoop(t *testing.T) {
testshared.NewRunnerBuilder(t).
WithArgs("--show-stats=false").
Expand Down
3 changes: 2 additions & 1 deletion test/testdata/notcompiles/typecheck.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
//golangcitest:args -Etypecheck
//golangcitest:args -Emodernize
//golangcitest:expected_linter typecheck
package testdata

fun NotCompiles() { // want "expected declaration, found.* fun"
Expand Down
3 changes: 2 additions & 1 deletion test/testdata/notcompiles/typecheck_many_issues.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
//go:build go1.20

//golangcitest:args -Etypecheck
//golangcitest:args -Emodernize
//golangcitest:expected_linter typecheck
package testdata

func TypeCheckBadCalls() {
Expand Down
Loading