fmcgeough

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

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

fmcgeough

Here’s a public repo that demos the issue. https://github.com/fmcgeough/google_sheet_dialyer

NobbZ

NobbZ

The PLT is building right now, I’ll take a look at it as my family gives me the time :wink:

OvermindDL1

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

Where Next?

Popular in Questions Top

_russellb
I want to try my hand at web scraping. What tools/libraries do I need to use. I’m hoping to turn this into something professional so don’...
New
Tee
can someone please explain to me how Enum.reduce works with maps
New
tduccuong
Hi, is there any work on GUI with Elixir, that is similar to Electron/Javascript? My idea is to bundle Phoenix and BEAM into a single se...
New
dokuzbir
I want to highlight html closing tags when i click a html tag. That works in .html files but doesnt work for html.eex templates. How can...
New
baxterw3b
Hi guys, i’m new in the Elixir world, and i have to say, that i love it! i’m having some problem to understand anonymous functions with ...
New
SoCreat
i’m a new one to elixir which editor can i use vs code? or atom? Thanks! :smiley:
New
RisingFromAshes
I’ve read in another post that it may be possible with a router helper - but I couldn’t find an appropriate one, and tbh, I’m still just ...
New
ashish173
I am using Ecto timestamps with postgres, I can see the timestamps() use the :naive_dateime but for my use case I wanted to store the ti...
New
WestKeys
Currently suffering from paralysis by [HTTP client] analysis. This is rather unusual in Elixirland as there tends to be consensus on the ...
New
marick
I had some trouble figuring out how to make many-to-many associations work. Once I got it working, I wrote a blog post. Because I’m a nov...
New

Other popular topics Top

senggen
Erlang/OTP 25 [erts-13.2.2] [source] [64-bit] [smp:8:8] [ds:8:8:10] [async-threads:1] 15:22:35.803 [error] gen_event {lager_file_backend...
New
Harrisonl
We have an ECS cluster with 4 services, where each task joins a single cluster, via discovery ECS discovery service. Currently when I de...
New
chrismccord
Phoenix 1.4.0 released Phoenix 1.4 is out! This release ships with exciting new features, most notably with HTTP2 support, improved deve...
688 30877 112
New
jay1
Why is it that the mnesia database isn’t the most preferred database for use in Elixir/Phoenix?
New
SoCreat
i’m a new one to elixir which editor can i use vs code? or atom? Thanks! :smiley:
New
Emily
I have VueJS GUIs with the project generated using Webpack. I have Elixir modules that will need to be used by the VueJS GUIs. I forese...
New
klo
Got a question about when to concat vs. prepending items to list then reversing to achieve appending. So i know lists boil down to [1 | ...
New
joaquinalcerro
Hi there, I am working with Ecto-Postgresql and I need to call all of the records from a specific table but the table has 40,000 records...
New
PeterCarter
There are pre-rolled solutions for other frameworks that do work. However, Phoenix does not seem to have these. Have people had good expe...
New
vonH
In asking this question I am more interested about the expressiveness of the language itself and less concerned about the availability of...
New

We're in Beta

About us Mission Statement