github.com/azazeal/revive@v1.0.9/testdata/empty-block.go (about)

     1  // Test of empty-blocks.
     2  
     3  package fixtures
     4  
     5  func f(x int) {} // Must not match
     6  
     7  type foo struct{}
     8  
     9  func (f foo) f(x *int)  {} // Must not match
    10  func (f *foo) g(y *int) {} // Must not match
    11  
    12  func g(f func() bool) {
    13  	{ // MATCH /this block is empty, you can remove it/
    14  	}
    15  
    16  	_ = func(e error) {} // Must not match
    17  
    18  	if ok := f(); ok { // MATCH /this block is empty, you can remove it/
    19  		// only a comment
    20  	} else {
    21  		println("it's NOT empty!")
    22  	}
    23  
    24  	if ok := f(); ok {
    25  		println("it's NOT empty!")
    26  	} else { // MATCH /this block is empty, you can remove it/
    27  
    28  	}
    29  
    30  	for i := 0; i < 10; i++ { // MATCH /this block is empty, you can remove it/
    31  
    32  	}
    33  
    34  	for { // MATCH /this block is empty, you can remove it/
    35  
    36  	}
    37  
    38  	// issue 386, then overwritten by issue 416
    39  	var c = make(chan int)
    40  	for range c { // MATCH /this block is empty, you can remove it/
    41  	}
    42  
    43  	var s = "a string"
    44  	for range s { // MATCH /this block is empty, you can remove it/
    45  	}
    46  
    47  }