Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

use ExMachina.Ecto defines functions with no local return #157

Closed
KronicDeth opened this issue Aug 23, 2016 · 3 comments
Closed

use ExMachina.Ecto defines functions with no local return #157

KronicDeth opened this issue Aug 23, 2016 · 3 comments

Comments

@KronicDeth
Copy link

In test/support/factory.ex, I have

  use ExMachina.Ecto., repo: MyApp.Repo

This works for the factories just fine, but mix dialyze thinks all function defined by the use have no local return:

test/support/factory.ex:22: Function create/1 has no local return

test/support/factory.ex:22: Function create/2 has no local return

test/support/factory.ex:22: Function create_list/3 has no local return

test/support/factory.ex:22: Function create_pair/2 has no local return

test/support/factory.ex:22: Function fields_for/1 has no local return

My work-around is

 @dialyzer {:no_return, create: 1, create: 2, create_list: 3, create_pair: 2, fields_for: 1}

Since the functions are only there to raise errors, their specs can say as much as the work-around would not be necessary. I'll open a PR to do that.

@KronicDeth
Copy link
Author

It turned out more complex than just those warnings because those were from Erlang 18.3 and Erlang 19.0+ gets a lot better dialyzer for maps, so there are more warnings on 19.0 that you're using on CircleCI. I can open a PR for just the 18.3 changes if you want.

@paulcsmith
Copy link
Contributor

Yeah I think just the changed for 18.3 would be a great start. Thanks so much for catching those :)

@jsteiner
Copy link
Contributor

@KronicDeth I'm going to close this for now, although we're more than willing to accept a PR for this if you get around to it.

germsvel pushed a commit that referenced this issue Jul 20, 2018
Fixes #157

Since version 1.0.0, when users of ex_machina try to call the deprecated fields_for/2 function, it raises an exception. This doesn't seem to provide any benefit. If instead it's removed, calls to it will fail at compile time. But if it stays in, calls will fail at runtime, possibly in production.

This PR solves the Dialyzer issue and it provides a better solution for dealing with the obsolete function.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants