Skip to content

Commit

Permalink
Merge pull request #830 from tealeg/staticcheck
Browse files Browse the repository at this point in the history
Apply changes suggested by staticcheck
  • Loading branch information
tealeg authored Nov 18, 2024
2 parents 3476977 + 0c9b983 commit acaf8a1
Show file tree
Hide file tree
Showing 22 changed files with 380 additions and 504 deletions.
16 changes: 0 additions & 16 deletions cell.go
Original file line number Diff line number Diff line change
Expand Up @@ -509,22 +509,6 @@ func (c *Cell) GetNumberFormat() string {
return c.NumFmt
}

func (c *Cell) formatToFloat(format string) (string, error) {
f, err := strconv.ParseFloat(c.Value, 64)
if err != nil {
return c.Value, err
}
return fmt.Sprintf(format, f), nil
}

func (c *Cell) formatToInt(format string) (string, error) {
f, err := strconv.ParseFloat(c.Value, 64)
if err != nil {
return c.Value, err
}
return fmt.Sprintf(format, int(f)), nil
}

// getNumberFormat will update the parsedNumFmt struct if it has become out of date, since a cell's NumFmt string is a
// public field that could be edited by clients.
func (c *Cell) getNumberFormat() *parsedNumberFormat {
Expand Down
14 changes: 2 additions & 12 deletions cell_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -629,7 +629,7 @@ func TestCell(t *testing.T) {
smallDate := time.Date(1899, 12, 30, 0, 0, 0, 1000, time.UTC)
smallExcelTime := TimeToExcelTime(smallDate, false)

c.Assert(true, qt.Equals, 0.0 != smallExcelTime)
c.Assert(0.0, qt.Not(qt.Equals), smallExcelTime)
roundTrippedDate := TimeFromExcelTime(smallExcelTime, false)
c.Assert(roundTrippedDate, qt.Equals, smallDate)
})
Expand Down Expand Up @@ -933,16 +933,6 @@ func (fvc *formattedValueChecker) Equals(cell Cell, expected string) {
fvc.c.Assert(val, qt.Equals, expected)
}

func cellsFormattedValueEquals(t *testing.T, cell *Cell, expected string) {
val, err := cell.FormattedValue()
if err != nil {
t.Error(err)
}
if val != expected {
t.Errorf("Expected cell.FormattedValue() to be %v, got %v", expected, val)
}
}

func TestCellMerge(t *testing.T) {
c := qt.New(t)
csRunO(c, "MergeAndSave", func(c *qt.C, option FileOption) {
Expand All @@ -956,7 +946,7 @@ func TestCellMerge(t *testing.T) {
cell := row.AddCell()
cell.Value = "test"
cell.Merge(1, 0)
path := filepath.Join(c.Mkdir(), "merged.xlsx")
path := filepath.Join(t.TempDir(), "merged.xlsx")
err = f.Save(path)
c.Assert(err, qt.Equals, nil)
})
Expand Down
Loading

0 comments on commit acaf8a1

Please sign in to comment.