Skip to content

Commit 7a70235

Browse files
committed
remove redundant else blocks
golint asks to remove else blocks when returning to improve readability.
1 parent 386e807 commit 7a70235

5 files changed

Lines changed: 9 additions & 18 deletions

File tree

builder.go

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,8 @@ func NewErrorBuilder(t *Type) *ErrorBuilder {
2222
getMode := func() callStackBuildMode {
2323
if t.modifiers.CollectStackTrace() {
2424
return stackTraceCollect
25-
} else {
26-
return stackTraceOmit
2725
}
26+
return stackTraceOmit
2827
}
2928

3029
return &ErrorBuilder{
@@ -136,9 +135,8 @@ func (eb *ErrorBuilder) borrowStackTraceFromCause() *stackTrace {
136135
originalStackTrace := eb.extractStackTraceFromCause(eb.cause)
137136
if originalStackTrace != nil {
138137
return originalStackTrace
139-
} else {
140-
return collectStackTrace()
141138
}
139+
return collectStackTrace()
142140
}
143141

144142
func (eb *ErrorBuilder) combineStackTraceWithCause() *stackTrace {

error.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -173,9 +173,8 @@ func (e *Error) Error() string {
173173
func (e *Error) fullMessage() string {
174174
if e.transparent {
175175
return e.messageWithUnderlyingInfo()
176-
} else {
177-
return joinStringsIfNonEmpty(": ", e.errorType.FullName(), e.messageWithUnderlyingInfo())
178176
}
177+
return joinStringsIfNonEmpty(": ", e.errorType.FullName(), e.messageWithUnderlyingInfo())
179178
}
180179

181180
func (e *Error) messageWithUnderlyingInfo() string {

namespace.go

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -105,17 +105,15 @@ func newNamespace(parent *Namespace, name string, traits ...Trait) Namespace {
105105
createName := func() string {
106106
if parent == nil {
107107
return name
108-
} else {
109-
return fmt.Sprintf("%s.%s", parent.FullName(), name)
110108
}
109+
return fmt.Sprintf("%s.%s", parent.FullName(), name)
111110
}
112111

113112
createModifiers := func() modifiers {
114113
if parent == nil {
115114
return noModifiers{}
116-
} else {
117-
return newInheritedModifiers(parent.modifiers)
118115
}
116+
return newInheritedModifiers(parent.modifiers)
119117
}
120118

121119
namespace := Namespace{

type.go

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -123,9 +123,8 @@ func newType(namespace Namespace, parent *Type, name string, traits ...Trait) *T
123123
collectModifiers := func() modifiers {
124124
if parent == nil {
125125
return newInheritedModifiers(namespace.modifiers)
126-
} else {
127-
return newInheritedModifiers(parent.modifiers)
128126
}
127+
return newInheritedModifiers(parent.modifiers)
129128
}
130129

131130
collectTraits := func() map[Trait]bool {
@@ -150,9 +149,8 @@ func newType(namespace Namespace, parent *Type, name string, traits ...Trait) *T
150149
createFullName := func() string {
151150
if parent == nil {
152151
return namespace.FullName() + "." + name
153-
} else {
154-
return parent.FullName() + "." + name
155152
}
153+
return parent.FullName() + "." + name
156154
}
157155

158156
t := &Type{

wrap.go

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -67,9 +67,8 @@ func DecorateMany(message string, errs ...error) error {
6767

6868
if areAllOfTheSameType(errs...) {
6969
return WrapMany(transparentWrapper, message, errs...)
70-
} else {
71-
return WrapMany(opaqueWrapper, message, errs...)
7270
}
71+
return WrapMany(opaqueWrapper, message, errs...)
7372
}
7473

7574
// WrapMany is a utility to wrap multiple errors.
@@ -110,9 +109,8 @@ func areAllOfTheSameType(errs ...error) bool {
110109

111110
if errorType != nil && errorType != typedError.Type() {
112111
return false
113-
} else {
114-
errorType = typedError.Type()
115112
}
113+
errorType = typedError.Type()
116114
}
117115

118116
return true

0 commit comments

Comments
 (0)