Repository: jeremyjh/dialyxir
Pull request #300 (2019-02-27 16:51:53)

Ensure plt_ignore_apps option works in umbrella
[This PR](https://github.com/jeremyjh/dialyxir/pull/296) does not work for umbrella projects because the plt_ignored_apps are subtracted before calling `Enum.uniq()` in plt list.

A fixture reproducing this situation has been added to ensure that this works.

jeremyjh: Thanks! I'd prefer to keep the fixtures really lean though, could you strip it down to the bare essentials for this test? Hopefully that is just three `mix.exs` files.
gilacost: > Thanks! I'd prefer to keep the fixtures really lean though, could you strip it down to the bare essentials for this test? Hopefully that is just three `mix.exs` files.

Is it ok like this?

Patch:
diff --git a/lib/dialyxir/project.ex b/lib/dialyxir/project.ex
index 2cf219c..6ff6072 100644
--- a/lib/dialyxir/project.ex
+++ b/lib/dialyxir/project.ex
@@ -45,11 +45,12 @@ defmodule Dialyxir.Project do
     Mix.Tasks.Deps.Loadpaths.run([])
     # compile & load current project paths
     Mix.Project.compile([])
-    apps = plt_apps() || plt_add_apps() ++ (include_deps() -- plt_ignore_apps())
+    apps = plt_apps() || plt_add_apps() ++ include_deps()
 
     apps
     |> Enum.sort()
     |> Enum.uniq()
+    |> Kernel.--(plt_ignore_apps())
   end
 
   def dialyzer_paths do


Test patch:
diff --git a/test/dialyxir/project_test.exs b/test/dialyxir/project_test.exs
index d5f5f74..9fe7302 100644
--- a/test/dialyxir/project_test.exs
+++ b/test/dialyxir/project_test.exs
@@ -162,4 +162,10 @@ defmodule Dialyxir.ProjectTest do
       assert Regex.match?(~r/Error loading nonexistent, dependency list may be incomplete/, out)
     end)
   end
+
+  test "igonored apps are removed in umbrella projects" do
+    in_project(:umbrella_ignore_apps, fn ->
+      refute Enum.member?(Project.cons_apps(), :logger)
+    end)
+  end
 end
diff --git a/test/fixtures/umbrella_ignore_apps/.gitignore b/test/fixtures/umbrella_ignore_apps/.gitignore
new file mode 100644
index 0000000..6e1db0f
--- /dev/null
+++ b/test/fixtures/umbrella_ignore_apps/.gitignore
@@ -0,0 +1,17 @@
+# The directory Mix will write compiled artifacts to.
+/_build
+
+# If you run "mix test --cover", coverage assets end up here.
+/cover
+
+# The directory Mix downloads your dependencies sources to.
+/deps
+
+# Where 3rd-party dependencies like ExDoc output generated docs.
+/doc
+
+# If the VM crashes, it generates a dump, let's ignore it too.
+erl_crash.dump
+
+# Also ignore archive artifacts (built via "mix archive.build").
+*.ez
diff --git a/test/fixtures/umbrella_ignore_apps/apps/first_one/mix.exs b/test/fixtures/umbrella_ignore_apps/apps/first_one/mix.exs
new file mode 100644
index 0000000..416dee3
--- /dev/null
+++ b/test/fixtures/umbrella_ignore_apps/apps/first_one/mix.exs
@@ -0,0 +1,25 @@
+defmodule FirstOne.Mixfile do
+  use Mix.Project
+
+  def project do
+    [
+      app: :first_one,
+      version: "0.1.0",
+      build_path: "../../_build",
+      config_path: "../../config/config.exs",
+      deps_path: "../../deps",
+      lockfile: "../../mix.lock",
+      elixir: "~> 1.3",
+      build_embedded: Mix.env() == :prod,
+      start_permanent: Mix.env() == :prod,
+      deps: []
+    ]
+  end
+
+  # Configuration for the OTP application
+  #
+  # Type "mix help compile.app" for more information
+  def application do
+    [applications: [:logger, :public_key]]
+  end
+end
diff --git a/test/fixtures/umbrella_ignore_apps/apps/second_one/mix.exs b/test/fixtures/umbrella_ignore_apps/apps/second_one/mix.exs
new file mode 100644
index 0000000..b3aa30b
--- /dev/null
+++ b/test/fixtures/umbrella_ignore_apps/apps/second_one/mix.exs
@@ -0,0 +1,25 @@
+defmodule SecondOne.Mixfile do
+  use Mix.Project
+
+  def project do
+    [
+      app: :second_one,
+      version: "0.1.0",
+      build_path: "../../_build",
+      config_path: "../../config/config.exs",
+      deps_path: "../../deps",
+      lockfile: "../../mix.lock",
+      elixir: "~> 1.3",
+      build_embedded: Mix.env() == :prod,
+      start_permanent: Mix.env() == :prod,
+      deps: []
+    ]
+  end
+
+  # Configuration for the OTP application
+  #
+  # Type "mix help compile.app" for more information
+  def application do
+    [applications: [:logger, :mix]]
+  end
+end
diff --git a/test/fixtures/umbrella_ignore_apps/mix.exs b/test/fixtures/umbrella_ignore_apps/mix.exs
new file mode 100644
index 0000000..43e248c
--- /dev/null
+++ b/test/fixtures/umbrella_ignore_apps/mix.exs
@@ -0,0 +1,15 @@
+defmodule UmbrellaIgnoreApps.Mixfile do
+  use Mix.Project
+
+  def project do
+    [
+      apps_path: "apps",
+      build_embedded: Mix.env() == :prod,
+      start_permanent: Mix.env() == :prod,
+      deps: [],
+      dialyzer: [
+        plt_ignore_apps: [:logger]
+      ]
+    ]
+  end
+end