fmcgeough

fmcgeough

Another Dialyzer puzzle - 'Function will never be called'

I’m using the https://github.com/GoogleCloudPlatform/elixir-google-api/tree/master/clients/sheets 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:

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

Tee
can someone please explain to me how Enum.reduce works with maps
New
itssasanka
Hi all, Trying to get some more clarity over utc_datetime and naive_datetime for Ecto: https://hexdocs.pm/ecto/Ecto.Schema.html#module-...
New
jononomo
I am trying to figure out how Mix knows whether the environment is test, dev, or prod -- where is this set? Thanks.
New
Kagamiiiii
Student & New to elixir. Nice language. I want to convert a english character, e.g. “a”, which is stored in a variable, to it’s asci...
New
vertexbuffer
Hello, can anybody help here..? I have a list of players and I what to delete an element, but every for loop the list is reverting to ori...
New
lastday4you
I wanted to check elixir version in phoenix because i found that my elixir is 1.5 but when i use Enum.chunk_by it said the function is un...
New
stefanchrobot
What’s the safe way to decode a JSON string into a struct? I want to avoid calling String.to_atom. Jason.decode can give me a map with st...
New
aadeshere1
I have a another noob question about loop. Since elixir is immutable, while loop is not directly possible. total = 10 while total != 0 ...
New
johnnyicon
Hi all, I've just started learning Elixir and Phoenix Framework, so please pardon my n00bness at this stage. I'm trying to use Postg...
New
Exadra37
Sometimes I want to check if the input into a function is not a blank string. My first approach: defmodule Example do def do_stuff(s...
New

Other popular topics Top

New
jononomo
I am trying to figure out how Mix knows whether the environment is test, dev, or prod -- where is this set? Thanks.
New
polypush135
As many of you may have realized by now (sorry for all the posts here) I’ve been working on a db problem where I’m trying to aggregate a ...
New
hariharasudhan94
I would like to know what is the best IDE for elixir development?
New
chrismccord
As promised, the first release candidate of Phoenix 1.3.0 is out! This release focuses on code generators with improved project structure...
New
freewebwithme
Using vs code and installed ElixirLS: support and debugger. And I got an error popped up on start up says Failed to run ‘elixir’ comma...
New
mgjohns61585
Could someone help me? I'm making my first elixir program, number guessing game. I can't figure out how to convert the user's guess from ...
New
aesmail
Hello guys, I have finally made it. I created an admin interface for a framework. It’s been on my todo list for years and with the curre...
New
vrod
I am using the Starship cross-shell prompt – it seems pretty nice, but I get some errors: [WARN] - (starship::utils): Executing command ...
New
lanycrost
Hi everyone! I need implement if…else if…else condition from my elixir code, and anymore of this control flow structures not work proper...
New

We're in Beta

About us Mission Statement