Skip to content

Commit

Permalink
Merge pull request #481 from pnezis/no-umbrella-cd
Browse files Browse the repository at this point in the history
Add `:no-umbrella` config option
  • Loading branch information
jeremyjh committed Mar 19, 2023
2 parents 90921cc + ed0df65 commit 8073eaa
Show file tree
Hide file tree
Showing 5 changed files with 56 additions and 1 deletion.
12 changes: 12 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -371,3 +371,15 @@ dialyzer: [

This option can also be set on the command line with `--list-unused-filters`. When used without
`--ignore-exit-status`, this option will result in an error status code.

#### `no_umbrella` flag

Projects with lockfiles at a parent folder are treated as umbrella projects. In some cases however
you may wish to have the lockfile on a parent folder without having an umbrella. By setting the
`no_umbrella` flag to `true` your project will be treated as a non umbrella project:

```elixir
dialyzer: [
no_umbrella: true
]
```
7 changes: 7 additions & 0 deletions lib/dialyxir/project.ex
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,13 @@ defmodule Dialyxir.Project do
Mix.Project.config()[:dialyzer][:flags] || []
end

def no_umbrella? do
case dialyzer_config()[:no_umbrella] do
true -> true
_other -> false
end
end

defp skip?({file, warning, line}, {file, warning, line, _}), do: true
defp skip?({file, warning}, {file, warning, _, _}), do: true
defp skip?({file}, {file, _, _, _}), do: true
Expand Down
5 changes: 4 additions & 1 deletion lib/mix/tasks/dialyzer.ex
Original file line number Diff line number Diff line change
Expand Up @@ -295,7 +295,10 @@ defmodule Mix.Tasks.Dialyzer do
end

defp in_child? do
String.contains?(Mix.Project.config()[:lockfile], "..")
case Project.no_umbrella?() do
true -> false
false -> String.contains?(Mix.Project.config()[:lockfile], "..")
end
end

defp no_plt? do
Expand Down
10 changes: 10 additions & 0 deletions test/dialyxir/project_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -184,4 +184,14 @@ defmodule Dialyxir.ProjectTest do
assert Project.list_unused_filters?(list_unused_filters: nil)
end)
end

test "no_umbrella? works as expected" do
in_project(:umbrella, fn ->
refute Project.no_umbrella?()
end)

in_project(:no_umbrella, fn ->
assert Project.no_umbrella?()
end)
end
end
23 changes: 23 additions & 0 deletions test/fixtures/no_umbrella/mix.exs
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
defmodule NoUmbrella.Mixfile do
use Mix.Project

def project do
[
app: :no_umbrella,
version: "0.1.0",
lockfile: "../mix.lock",
elixir: "~> 1.3",
build_embedded: Mix.env() == :prod,
start_permanent: Mix.env() == :prod,
deps: [],
dialyzer: [no_umbrella: true]
]
end

# Configuration for the OTP application
#
# Type "mix help compile.app" for more information
def application do
[applications: [:logger, :public_key]]
end
end

0 comments on commit 8073eaa

Please sign in to comment.