github.com/songshiyun/revive@v1.1.5-0.20220323112655-f8433a19b3c5/testdata/empty-lines.go (about)

     1  // Test of empty-lines.
     2  
     3  package fixtures
     4  
     5  import "time"
     6  
     7  func f1(x *int) bool { // MATCH /extra empty line at the start of a block/
     8  
     9  	return x > 2
    10  }
    11  
    12  func f2(x *int) bool {
    13  	return x > 2 // MATCH /extra empty line at the end of a block/
    14  
    15  }
    16  
    17  func f3(x *int) bool { // MATCH /extra empty line at the start of a block/
    18  
    19  	return x > 2 // MATCH /extra empty line at the end of a block/
    20  
    21  }
    22  
    23  func f4(x *int) bool {
    24  	// This is fine.
    25  	return x > 2
    26  }
    27  
    28  func f5(x *int) bool { // MATCH /extra empty line at the start of a block/
    29  
    30  	// This is _not_ fine.
    31  	return x > 2
    32  }
    33  
    34  func f6(x *int) bool {
    35  	return x > 2
    36  	// This is fine.
    37  }
    38  
    39  func f7(x *int) bool {
    40  	return x > 2 // MATCH /extra empty line at the end of a block/
    41  	// This is _not_ fine.
    42  
    43  }
    44  
    45  func f8(*int) bool {
    46  	if x > 2 { // MATCH /extra empty line at the start of a block/
    47  
    48  		return true
    49  	}
    50  
    51  	return false
    52  }
    53  
    54  func f9(*int) bool {
    55  	if x > 2 {
    56  		return true // MATCH /extra empty line at the end of a block/
    57  
    58  	}
    59  
    60  	return false
    61  }
    62  
    63  func f10(*int) bool { // MATCH /extra empty line at the start of a block/
    64  
    65  	if x > 2 {
    66  		return true
    67  	}
    68  
    69  	return false
    70  }
    71  
    72  func f11(x *int) bool {
    73  	if x > 2 {
    74  		return true
    75  	}
    76  }
    77  
    78  func f12(x *int) bool {
    79  	if x > 2 { // MATCH /extra empty line at the end of a block/
    80  		return true
    81  	}
    82  
    83  }
    84  
    85  func f13(x *int) bool {
    86  	switch {
    87  	case x == 2:
    88  		return false
    89  	}
    90  }
    91  
    92  func f14(x *int) bool {
    93  	switch { // MATCH /extra empty line at the end of a block/
    94  	case x == 2:
    95  		return false
    96  	}
    97  
    98  }
    99  
   100  func f15(x *int) bool {
   101  	switch {
   102  	case x == 2: // MATCH /extra empty line at the end of a block/
   103  		return false
   104  
   105  	}
   106  }
   107  
   108  func f16(x *int) bool {
   109  	return Query(
   110  		qm("x = ?", x),
   111  	).Execute()
   112  }
   113  
   114  func f17(x *int) bool {
   115  	return Query( // MATCH /extra empty line at the end of a block/
   116  		qm("x = ?", x),
   117  	).Execute()
   118  
   119  }
   120  
   121  func f18(x *int) bool {
   122  	if true {
   123  		if true { // MATCH /extra empty line at the end of a block/
   124  			return true
   125  		}
   126  
   127  		// TODO: should we handle the error here?
   128  	}
   129  
   130  	return false
   131  }
   132  
   133  func w() {
   134  	select {
   135  	case <-time.After(dur):
   136  		// TODO: Handle Ctrl-C is pressed in `mysql` client.
   137  		// return 1 when SLEEP() is KILLed
   138  	}
   139  	return 0, false, nil
   140  }
   141  
   142  func x() {
   143  	if tagArray[2] == "req" {
   144  		bit := len(u.reqFields)
   145  		u.reqFields = append(u.reqFields, name)
   146  		reqMask = uint64(1) << uint(bit)
   147  		// TODO: if we have more than 64 required fields, we end up
   148  		// not verifying that all required fields are present.
   149  		// Fix this, perhaps using a count of required fields?
   150  	}
   151  
   152  	if err == nil { // No need to refresh if the stream is over or failed.
   153  		// Consider any buffered body data (read from the conn but not
   154  		// consumed by the client) when computing flow control for this
   155  		// stream.
   156  		v := int(cs.inflow.available()) + cs.bufPipe.Len()
   157  		if v < transportDefaultStreamFlow-transportDefaultStreamMinRefresh {
   158  			streamAdd = int32(transportDefaultStreamFlow - v)
   159  			cs.inflow.add(streamAdd)
   160  		}
   161  	}
   162  }