jeremyjh / dialyxir

Mix tasks to simplify use of Dialyzer in Elixir projects.
Apache License 2.0
1.69k stars 141 forks source link

Question: Running `mix dialyzer` and saving output error tuples to list for comparing old/new errors? #486

Closed Nezteb closed 1 year ago

Nezteb commented 1 year ago

Several months ago I watched this talk on dialyzer: https://www.youtube.com/watch?v=4PZE40h13wM

I'd like to replicate some of what the speaker was talking about: adding dialyzer to a large existing project but only failing the CI typecheck step if new errors are added.

Upon adding dialyxir to my employer's main Elixir service, mix dialyzer gives:

Total errors: 568, Skipped: 40, Unnecessary Skips: 0

Not too bad!..? (😓)

Here's a theoretical mix task I would like to create: https://gist.github.com/Nezteb/eb654f399fa599d0805d38d9a4b56da4

Currently when running output = Mix.Task.run("dialyzer", ["--quiet", "--format", "ignore_file"]), I get nothing as output because the dialyzer mix task prints to standard out.

Is there a way for me to acquire a list of the error tuples so that I can compare them to a known set of similar error tuples?

If not, my next attempt would be to use a bash script and compare the raw text output of mix dialyzer --quiet --format ignore_file with a dialyzer-errors.txt file (or something like that), but that wouldn't be ideal.

Any and all ideas would be appreciated!

jeremyjh commented 1 year ago

Does mix dialyzer --format ignore_file >> .dialyzer_ignore.exs not achieve this? If you want to use dialyxir as more like a library its probably already quite close to being able to do that and I'm happy to accept PRs that support that.

Nezteb commented 1 year ago

OHHHHH, holy cow that's awesome. That combined with list_unused_filters: true does exactly what I want.

I think I misunderstood how .dialyzer_ignore.exs could be used: I thought it was only for situations like "we don't ever care about fixing :no_return types, so we'll just blanket ignore them".

Thank you a ton Jeremy!