Skip to content

Commit

Permalink
Merge pull request #495 from Nezteb/master
Browse files Browse the repository at this point in the history
Add warning for deprecated option: plt_add_deps: true
  • Loading branch information
jeremyjh committed May 2, 2023
2 parents eed8ddf + f92f2dd commit f99635c
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 4 deletions.
3 changes: 3 additions & 0 deletions lib/dialyxir/output.ex
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@ defmodule Dialyxir.Output do
def info(""), do: :ok
def info(text), do: Mix.shell().info(text)

def warning(""), do: :ok
def warning(text), do: Mix.shell().info(color(text, :yellow))

def error(""), do: :ok
def error(text), do: Mix.shell().error(text)
end
12 changes: 8 additions & 4 deletions lib/dialyxir/project.ex
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
defmodule Dialyxir.Project do
@moduledoc false
import Dialyxir.Output, only: [info: 1, error: 1]
import Dialyxir.Output

alias Dialyxir.FilterMap
alias Dialyxir.Formatter.Short
Expand Down Expand Up @@ -34,7 +34,7 @@ defmodule Dialyxir.Project do

def check_config do
if is_binary(dialyzer_config()[:plt_file]) do
info("""
warning("""
Notice: :plt_file is deprecated as Dialyxir now uses project-private PLT files by default.
If you want to use this setting without seeing this warning, provide it in a pair
with the :no_warn key e.g. `dialyzer: plt_file: {:no_warn, "~/mypltfile"}`
Expand Down Expand Up @@ -316,10 +316,14 @@ defmodule Dialyxir.Project do

# compatibility
true ->
warning(
"Dialyxir has deprecated plt_add_deps: true in favor of apps_direct, which includes only runtime dependencies."
)

deps_project() ++ deps_app(false)

:project ->
info(
warning(
"Dialyxir has deprecated plt_add_deps: :project in favor of apps_direct, which includes only runtime dependencies."
)

Expand All @@ -329,7 +333,7 @@ defmodule Dialyxir.Project do
deps_app(false)

:transitive ->
info(
warning(
"Dialyxir has deprecated plt_add_deps: :transitive in favor of app_tree, which includes only runtime dependencies."
)

Expand Down
7 changes: 7 additions & 0 deletions test/dialyxir/project_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,13 @@ defmodule Dialyxir.ProjectTest do
end)
end

test "Deprecation warning on use of plt_add_deps: true" do
in_project(:plt_add_deps_deprecations, fn ->
out = capture_io(&Project.cons_apps/0)
assert Regex.match?(~r/.*deprecated.*plt_add_deps.*/, out)
end)
end

test "list_unused_filters? works as intended" do
assert Project.list_unused_filters?(list_unused_filters: true)
refute Project.list_unused_filters?(list_unused_filters: nil)
Expand Down
13 changes: 13 additions & 0 deletions test/fixtures/plt_add_deps_deprecations/mix.exs
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
defmodule PltAddDepsDeprecations.Mixfile do
use Mix.Project

def project do
[
app: :plt_add_deps_deprecations,
version: "0.1.0",
dialyzer: [
plt_add_deps: true
]
]
end
end

0 comments on commit f99635c

Please sign in to comment.