jeremyjh / dialyxir

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

Support multiple formatters #538

Open axelson opened 1 month ago

axelson commented 1 month ago

Fixes #530

One scenario where multiple formatters is helpful is on CI where you want to use the GitHub formatter along with a more verbose formatter to see more about the specific failures (especially when viewing the CI logs directly).

I add :logger to give the user a warning message if they provide an invalid name for a formatter but I can remove the warning if there's a specific reason to not depend on logger.

Example run:

> mix dialyzer --format github --format dialyxir
Finding suitable PLTs
Checking PLT...
[:compiler, :crypto, :dialyxir, :dialyzer, :elixir, :erlex, :erts, :kernel, :logger, :mix, :stdlib, :syntax_tools, :weather]
PLT is up to date!
No :ignore_warnings opt specified in mix.exs and default does not exist.

Starting Dialyzer
[
  check_plt: false,
  init_plt: ~c"/Users/jasonaxelson/dev/tmp/weather/_build/dev/dialyxir_erlang-26.2.5_elixir-1.17.2_deps-dev.plt",
  files: [~c"/Users/jasonaxelson/dev/tmp/weather/_build/dev/lib/weather/ebin/Elixir.BusinessLogic.beam",
   ~c"/Users/jasonaxelson/dev/tmp/weather/_build/dev/lib/weather/ebin/Elixir.Weather.beam",
   ~c"/Users/jasonaxelson/dev/tmp/weather/_build/dev/lib/weather/ebin/Elixir.WeatherAPI.beam",
   ~c"/Users/jasonaxelson/dev/tmp/weather/_build/dev/lib/weather/ebin/Elixir.WeatherImpl.beam"],
  warnings: [:unknown]
]
Total errors: 2, Skipped: -2, Unnecessary Skips: 0
done in 0m3.44s
::warning file=lib/weather_impl.ex,line=5,title=callback_type_mismatch::Type mismatch for @callback get_weather.
lib/weather_impl.ex:5:callback_type_mismatch
Type mismatch for @callback get_weather/1 in WeatherAPI behaviour.

Expected type:
{:error, binary()} | {:ok, map()}

Actual type:
:ok

________________________________________________________________________________
::warning file=lib/weather_impl.ex,line=11,title=callback_type_mismatch::Type mismatch for @callback fetch_weather.
lib/weather_impl.ex:11:callback_type_mismatch
Type mismatch for @callback fetch_weather/1 in WeatherAPI behaviour.

Expected type:
{:error, binary()} | {:ok, map()}

Actual type:
:ok

________________________________________________________________________________
done (warnings were emitted)
Halting VM with exit status 2
axelson commented 5 days ago

@jeremyjh Ping! Do you have any thoughts on this PR?

jeremyjh commented 4 days ago

@axelson Sorry, was just very busy and then forgot to get back to this. I really appreciate the contribution! Would you mind adding an update to the docs for this?

axelson commented 3 days ago

No worries! I've definitely taken significantly longer to respond to PRs 😅

Yeah I'll take a first crack at adding docs for this 👍