fmcgeough
Another Dialyzer puzzle - 'Function will never be called'
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?
Marked As Solved
NobbZ
Its an upstream issue:
lib/google_api/sheets/v4/api/spreadsheets.ex:114: Function sheets_spreadsheets_create/1 has no local return
lib/google_api/sheets/v4/api/spreadsheets.ex:114: Function sheets_spreadsheets_create/2 has no local return
edit
I took the freedom to file an issue:
https://github.com/GoogleCloudPlatform/elixir-google-api/issues/73
Also Liked
fmcgeough
Here’s a public repo that demos the issue. https://github.com/fmcgeough/google_sheet_dialyer
NobbZ
The PLT is building right now, I’ll take a look at it as my family gives me the time ![]()
OvermindDL1
I’m kind of thinking it dies on the Spreadsheets.sheets_spreadsheets_create call from just an initial look?
EDIT: This is the dialyzer results if anyone is curious on that repo:
lib/google_spreadsheet.ex:22: Function deployments_sheet/0 has no local return
lib/google_spreadsheet.ex:34: Function create_google_sheet/1 has no local return
lib/google_spreadsheet.ex:55: Function get_spreadsheet/1 will never be called
Popular in Questions
Other popular topics
Categories:
Sub Categories:
Forums
Popular Tags
- #ecto
- #liveview
- #troubleshooting
- #learning-elixir
- #deployment
- #library
- #erlang
- #testing
- #genserver
- #mix
- #absinthe
- #remote-other
- #otp
- #plug
- #how-to-question
- #macros
- #postgres
- #channels
- #elixirconf
- #exunit
- #discussion
- #javascript
- #code-sync
- #podcasts
- #onsite
- #dialyzer
- #docker
- #authentication
- #umbrella
- #full-time-contract
- #podcasts-by-brainlid
- #ecto-query
- #elixir-ls
- #phoenix_html
- #iex
- #blog-post
- #graphql
- #genstage
- #ai
- #websockets
- #supervisor
- #advent-of-code
- #elixirconf-us
- #distillery
- #processes
- #forms
- #api
- #metaprogramming
- #security
- #performance








