redundant return statement
50}
51
52func (a *PendingAttestation) SetSignature(sig []byte) {
53 return54}
55
56func (a *PendingAttestation) GetSignature() []byte {
redundant return statement
46}
47
48func (a *PendingAttestation) SetCommitteeBits(bits bitfield.Bitlist) {
49 return50}
51
52func (a *PendingAttestation) SetSignature(sig []byte) {
redundant return statement
22}
23
24func (a *Attestation) SetCommitteeBits(bits bitfield.Bitlist) {
25 return26}
27
28func (a *Attestation) SetSignature(sig []byte) {
Description
Omit redundant control flow in your Go code.
Following cases should be considered to omit redundant control flow:
- Functions that have no return value do not need a return statement as the final statement of the function.
- The
switch
statement in Go does not have automatic fallthrough, unlike languages like C. It is unnecessary to have a break statement as the final statement in a case block.
Bad practice
func foo() {
fmt.Println("foo")
return
}
switch 1 {
case 1:
fmt.Println(“case one“)
break
case 2:
fmt.Println(“case two“)
}
Recommended
func foo() {
fmt.Println("foo")
}
switch 1 {
case 1:
fmt.Println(“case one“)
case 2:
fmt.Println(“case two“)
}