I’m using the elixir-google-api/clients/sheets at main · googleapis/elixir-google-api · GitHub project (a thin wrapper over the Google Sheets API) to create a Google sheet. The module that creates the sheets for us has a number of Dialyzer warnings but they are all the same root cause I’d imagine. The warning is “Function get_spreadsheet/1 will never be called” (where get_spreadsheet/1 is just an example).
Here’s the lead to that issue:
defp create_google_sheet(nil) do
Logger.info("No spreadsheet exists, creating one")
month = @months[DateTime.utc_now().month]
create_google_connection()
|> Spreadsheets.sheets_spreadsheets_create(
body: %{properties: %{title: "#{month}-#{DateTime.utc_now().year}-Deployment/Build Report"}}
)
|> get_spreadsheet()
end
The get_spreadsheet is just a shim to parse out the {:ok, response} or :error returned by sheets_spreadsheets_create. Here’s the one
defp get_spreadsheet(result) do
case result do
{:ok, response} -> response
{:error, _env} -> nil
end
end
Spreadsheets.sheets_spreadsheets_create spec is:
@spec sheets_spreadsheets_create(Tesla.Env.client, keyword()) :: {:ok, GoogleApi.Sheets.V4.Model.Spreadsheet.t} | {:error, Tesla.Env.t}
This functions fine. We’ve been running it in production for a month or so and it does exactly what we want but it bothers me that I don’t understand what dialyzer is trying to tell me. Any suggestions on what to look at?






















