Skip to content

Commit 3959b42

Browse files
committed
Remove unnecessary function
endsInComma was unnecessary since it's handled by a lineGroup method.
1 parent c6b6ae4 commit 3959b42

1 file changed

Lines changed: 2 additions & 6 deletions

File tree

keepsorted/block.go

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -385,7 +385,7 @@ func handleTrailingComma(lgs []*lineGroup) (trimTrailingComma func([]*lineGroup)
385385
}
386386
}
387387

388-
if n := len(dataGroups); n > 1 && allEndInComma(dataGroups[0:n-1]) && !endInComma(dataGroups[n-1]) {
388+
if n := len(dataGroups); n > 1 && allEndInComma(dataGroups[0:n-1]) && !dataGroups[n-1].matchesSuffix(commaLineEnd) {
389389
if dataGroups[n-1].matchesSuffix(commentLineEnd) {
390390
dataGroups[n-1].replaceSuffix(commentLineEnd, ", $2")
391391
} else {
@@ -411,7 +411,7 @@ func handleTrailingComma(lgs []*lineGroup) (trimTrailingComma func([]*lineGroup)
411411

412412
func allEndInComma(lgs []*lineGroup) bool {
413413
for _, lg := range lgs {
414-
if !endInComma(lg) {
414+
if !lg.matchesSuffix(commaLineEnd) {
415415
return false
416416
}
417417
}
@@ -422,7 +422,3 @@ var (
422422
commaLineEnd = regexp.MustCompile("(,)( *)((#|//).*)?$")
423423
commentLineEnd = regexp.MustCompile("( *)((#|//).*)$")
424424
)
425-
426-
func endInComma(lg *lineGroup) bool {
427-
return lg.matchesSuffix(commaLineEnd)
428-
}

0 commit comments

Comments
 (0)