jeremyjh / dialyxir

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

Fix OptionParser deprecation warning on `mix dialyzer.explain` #342

Closed rodrigues closed 5 years ago

rodrigues commented 5 years ago

This fixes a deprecation warning when calling mix dialyzer.explain.

➜ mix dialyzer.explain invalid_contract
warning: not passing the :switches or :strict option to OptionParser is deprecated
  (elixir) lib/option_parser.ex:607: OptionParser.build_config/1
  (elixir) lib/option_parser.ex:231: OptionParser.parse/2
  lib/mix/tasks/dialyzer/explain.ex:22: Mix.Tasks.Dialyzer.Explain.run/1
  (mix) lib/mix/task.ex:331: Mix.Task.run_task/3
  (mix) lib/mix/cli.ex:79: Mix.CLI.run_task/2

The @spec for the function does not match the success typing of
the function.

Example:

defmodule Example do
  @spec process(:error) :: :ok
  def process(:ok) do
    :ok
  end
end

The @spec in this case claims that the function accepts a parameter :error
but the function head only accepts :ok, resulting in the mismatch.