github.com/vanstinator/golangci-lint@v0.0.0-20240223191551-cc572f00d9d1/test/testdata/nakedret.go (about)

     1  //golangcitest:args -Enakedret
     2  package testdata
     3  
     4  import "fmt"
     5  
     6  func NakedretIssue() (a int, b string) {
     7  	if a > 0 {
     8  		return // want "naked return in func `NakedretIssue` with 33 lines of code"
     9  	}
    10  
    11  	fmt.Println("nakedret")
    12  
    13  	if b == "" {
    14  		return 0, "0"
    15  	}
    16  
    17  	// ...
    18  	// ...
    19  	// ...
    20  	// ...
    21  	// ...
    22  	// ...
    23  	// ...
    24  	// ...
    25  	// ...
    26  	// ...
    27  	// ...
    28  	// ...
    29  	// ...
    30  	// ...
    31  	// ...
    32  	// ...
    33  	// ...
    34  	// ...
    35  	// ...
    36  
    37  	// len of this function is 33
    38  	return // want "naked return in func `NakedretIssue` with 33 lines of code"
    39  }
    40  
    41  func NoNakedretIssue() (a int, b string) {
    42  	if a > 0 {
    43  		return
    44  	}
    45  
    46  	if b == "" {
    47  		return 0, "0"
    48  	}
    49  
    50  	// ...
    51  	// ...
    52  	// ...
    53  	// ...
    54  	// ...
    55  	// ...
    56  	// ...
    57  	// ...
    58  	// ...
    59  	// ...
    60  	// ...
    61  	// ...
    62  	// ...
    63  	// ...
    64  	// ...
    65  	// ...
    66  	// ...
    67  	// ...
    68  
    69  	// len of this function is 30
    70  	return
    71  }