github.com/songrgg/gometalinter@v2.0.6-0.20180425200507-2cbec6168e84+incompatible/regressiontests/gosimple_test.go (about)

     1  package regressiontests
     2  
     3  import "testing"
     4  
     5  func TestGoSimple(t *testing.T) {
     6  	t.Parallel()
     7  	source := `package test
     8  
     9  func a(ok bool, ch chan bool) {
    10  	select {
    11  	case <- ch:
    12  	}
    13  
    14  	for {
    15  		select {
    16  		case <- ch:
    17  		}
    18  	}
    19  
    20  	if ok == true {
    21  	}
    22  }
    23  `
    24  	expected := Issues{
    25  		{Linter: "gosimple", Severity: "warning", Path: "test.go", Line: 4, Col: 2, Message: "should use a simple channel send/receive instead of select with a single case (S1000)"},
    26  		{Linter: "gosimple", Severity: "warning", Path: "test.go", Line: 8, Col: 2, Message: "should use for range instead of for { select {} } (S1000)"},
    27  		{Linter: "gosimple", Severity: "warning", Path: "test.go", Line: 14, Col: 5, Message: "should omit comparison to bool constant, can be simplified to ok (S1002)"},
    28  	}
    29  	ExpectIssues(t, "gosimple", source, expected)
    30  }