Skip to content

Commit 0aa67e7

Browse files
authored
Merge pull request #503 from k1LoW/modernize
fix: resolve modernize lint errors in apply.go and table.go
2 parents 260a210 + cb7c762 commit 0aa67e7

File tree

3 files changed

+14
-13
lines changed

3 files changed

+14
-13
lines changed

.golangci.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ linters:
99
- misspell
1010
- revive
1111
- funcorder
12+
- modernize
1213
settings:
1314
errcheck:
1415
check-type-assertions: true

apply.go

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -612,15 +612,15 @@ func (d *Deck) applyParagraphsRequests(objectID string, paragraphs []*Paragraph)
612612

613613
bulletRanges := map[int]*bulletRange{}
614614
count := int64(0)
615-
text := ""
615+
var textBuilder strings.Builder
616616
bulletStartIndex := int64(0) // reset per body
617617
bulletEndIndex := int64(0) // reset per body
618618
currentBullet := BulletNone
619619
for j, paragraph := range paragraphs {
620620
plen := 0
621621
if paragraph.Bullet != BulletNone {
622622
if paragraph.Nesting > 0 {
623-
text += strings.Repeat("\t", paragraph.Nesting)
623+
textBuilder.WriteString(strings.Repeat("\t", paragraph.Nesting))
624624
plen += paragraph.Nesting
625625
}
626626
}
@@ -647,11 +647,11 @@ func (d *Deck) applyParagraphsRequests(objectID string, paragraphs []*Paragraph)
647647
})
648648
}
649649
plen += flen
650-
text += fValue
650+
textBuilder.WriteString(fValue)
651651
}
652652

653653
if len(paragraphs) > j+1 {
654-
text += "\n"
654+
textBuilder.WriteString("\n")
655655
plen++
656656
}
657657

@@ -675,7 +675,7 @@ func (d *Deck) applyParagraphsRequests(objectID string, paragraphs []*Paragraph)
675675
reqs = append(reqs, &slides.Request{
676676
InsertText: &slides.InsertTextRequest{
677677
ObjectId: objectID,
678-
Text: text,
678+
Text: textBuilder.String(),
679679
},
680680
})
681681
var bulletRangeSlice []*bulletRange
@@ -840,7 +840,7 @@ func (d *Deck) updateLayout(ctx context.Context, index int, slide *Slide) (err e
840840

841841
var paragraphInfos []paragraphInfo
842842
currentIndex := int64(0)
843-
text := ""
843+
var textBuilder strings.Builder
844844
shapeObjectID := fmt.Sprintf("shape-%s", uuid.New().String())
845845

846846
for _, textElement := range element.Shape.Text.TextElements {
@@ -864,12 +864,12 @@ func (d *Deck) updateLayout(ctx context.Context, index int, slide *Slide) (err e
864864
if paragraphInfos[len(paragraphInfos)-1].nestingLevel > 0 {
865865
// Add tabs for nesting
866866
tabs := strings.Repeat("\t", int(paragraphInfos[len(paragraphInfos)-1].nestingLevel))
867-
text += tabs
867+
textBuilder.WriteString(tabs)
868868
currentIndex += int64(countString(tabs))
869869
}
870870
}
871871

872-
text += runText
872+
textBuilder.WriteString(runText)
873873

874874
// Adjust style indices based on actual position in new text
875875
if textElement.TextRun.Style != nil {
@@ -922,7 +922,7 @@ func (d *Deck) updateLayout(ctx context.Context, index int, slide *Slide) (err e
922922
insertReqs = append(insertReqs, &slides.Request{
923923
InsertText: &slides.InsertTextRequest{
924924
ObjectId: shapeObjectID,
925-
Text: strings.TrimSuffix(text, "\n"),
925+
Text: strings.TrimSuffix(textBuilder.String(), "\n"),
926926
},
927927
})
928928

table.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -518,8 +518,8 @@ func (d *Deck) applyTableCellStyles(tableObjectID string, table *Table) []*slide
518518
return nil
519519
}
520520

521-
for rowIdx := 0; rowIdx < rows; rowIdx++ {
522-
for colIdx := 0; colIdx < cols; colIdx++ {
521+
for rowIdx := range rows {
522+
for colIdx := range cols {
523523
cellStyle := d.tableStyle.cellStyle(rowIdx, colIdx)
524524
if cellStyle == nil {
525525
continue
@@ -654,8 +654,8 @@ func (d *Deck) applyTableBorderStyles(tableObjectID string, table *Table) []*sli
654654
}
655655

656656
// Apply inner borders per cell based on position
657-
for rowIdx := 0; rowIdx < rows; rowIdx++ {
658-
for colIdx := 0; colIdx < cols; colIdx++ {
657+
for rowIdx := range rows {
658+
for colIdx := range cols {
659659
isHeaderRow := rowIdx == 0
660660
isFirstCol := colIdx == 0
661661
isLastRow := rowIdx == rows-1

0 commit comments

Comments
 (0)