xou/elixlsx

Dialyzer warning on Workbook.append_sheet()

Opened this issue · 0 comments

This code, as given in the doc example, works but generates a dialyzer warning about breaking the contract:

Workbook.append_sheet(%Workbook{}, Sheet.with_name("blah"))

This does not:

bogus_sheet = Sheet.with_name("Unused")
Workbook.append_sheet(%Workbook{sheets: [bogus_sheet]}, Sheet.with_name("blah))

But of course that gives us two sheets.

The problem appears to be in the Workbook module, line 16, which defines sheets as nonempty_list. This makes sense once the sheet is created, but not during creation.

The workaround might be to avoid append_sheet for creation and use %Workbook{sheets: [sheet]} instead.

Suggestion: add a Workbook.new(sheet) function.