danschultzer / premailex

Preflight for your HTML emails - inline styling and plain text.
MIT License
170 stars 19 forks source link

Dialyzer: Function premail/1 has no local return. #70

Closed pehbehbeh closed 2 years ago

pehbehbeh commented 2 years ago

With the newest version 0.3.14 we get the following Dialyzer errors:

lib/myproject/emails/my_first_email.ex:12:no_return
Function my_mail/2 has no local return.
________________________________________________________________________________
lib/myproject/emails/my_second_email.ex:13:no_return
Function my_mail/2 has no local return.
________________________________________________________________________________
lib/myproject/mailer.ex:18:no_return
Function premail/1 has no local return.
________________________________________________________________________________
lib/myproject/workers/my_worker.ex:17:no_return
Function perform/1 has no local return.
________________________________________________________________________________

Main problem here is the premail/1 function. All other errors are follow-up errors of this code:

  def premail(email) do
    html = Premailex.to_inline_css(email.html_body)
    text = Premailex.to_text(email.html_body)

    email
    |> Swoosh.Email.html_body(html)
    |> Swoosh.Email.text_body(text)
  end

Given the fact, that this is the exact example from the documentation, i suspect the problem is further down the stack?

If I remove the CSS part, there is no error at all:

  def premail(email) do
    text = Premailex.to_text(email.html_body)

    email
    |> Swoosh.Email.text_body(text)
  end
danschultzer commented 2 years ago

Thanks @pehbehbeh, didn't have dialyzer running in vscode so didn't catch it before release 🤦 v0.3.15 is now out with the fix.

pehbehbeh commented 2 years ago

Awesome, thanks for the quick fix! <3