Skip to content

Commit 1416919

Browse files
committed
path_resolver.go: use switch instead of chained ifs
This improves the linter's joy.
1 parent 0308dfd commit 1416919

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

sizes/path_resolver.go

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -134,12 +134,13 @@ func (p *Path) TreePrefix() string {
134134
return "???"
135135
}
136136
case "commit", "tag":
137-
if p.parent != nil {
137+
switch {
138+
case p.parent != nil:
138139
// The parent is a tag.
139140
return fmt.Sprintf("%s^{%s}", p.parent.BestPath(), p.objectType)
140-
} else if p.relativePath != "" {
141+
case p.relativePath != "":
141142
return p.relativePath + ":"
142-
} else {
143+
default:
143144
return p.OID.String() + ":"
144145
}
145146
default:
@@ -164,12 +165,13 @@ func (p *Path) Path() string {
164165
return ""
165166
}
166167
case "commit", "tag":
167-
if p.parent != nil {
168+
switch {
169+
case p.parent != nil:
168170
// The parent is a tag.
169171
return fmt.Sprintf("%s^{%s}", p.parent.BestPath(), p.objectType)
170-
} else if p.relativePath != "" {
172+
case p.relativePath != "":
171173
return p.relativePath
172-
} else {
174+
default:
173175
return ""
174176
}
175177
default:

0 commit comments

Comments
 (0)