Skip to content

Commit 8073eaa

Browse files
authored
Merge pull request #481 from pnezis/no-umbrella-cd
Add `:no-umbrella` config option
2 parents 90921cc + ed0df65 commit 8073eaa

File tree

5 files changed

+56
-1
lines changed

5 files changed

+56
-1
lines changed

README.md

+12
Original file line numberDiff line numberDiff line change
@@ -371,3 +371,15 @@ dialyzer: [
371371

372372
This option can also be set on the command line with `--list-unused-filters`. When used without
373373
`--ignore-exit-status`, this option will result in an error status code.
374+
375+
#### `no_umbrella` flag
376+
377+
Projects with lockfiles at a parent folder are treated as umbrella projects. In some cases however
378+
you may wish to have the lockfile on a parent folder without having an umbrella. By setting the
379+
`no_umbrella` flag to `true` your project will be treated as a non umbrella project:
380+
381+
```elixir
382+
dialyzer: [
383+
no_umbrella: true
384+
]
385+
```

lib/dialyxir/project.ex

+7
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,13 @@ defmodule Dialyxir.Project do
109109
Mix.Project.config()[:dialyzer][:flags] || []
110110
end
111111

112+
def no_umbrella? do
113+
case dialyzer_config()[:no_umbrella] do
114+
true -> true
115+
_other -> false
116+
end
117+
end
118+
112119
defp skip?({file, warning, line}, {file, warning, line, _}), do: true
113120
defp skip?({file, warning}, {file, warning, _, _}), do: true
114121
defp skip?({file}, {file, _, _, _}), do: true

lib/mix/tasks/dialyzer.ex

+4-1
Original file line numberDiff line numberDiff line change
@@ -295,7 +295,10 @@ defmodule Mix.Tasks.Dialyzer do
295295
end
296296

297297
defp in_child? do
298-
String.contains?(Mix.Project.config()[:lockfile], "..")
298+
case Project.no_umbrella?() do
299+
true -> false
300+
false -> String.contains?(Mix.Project.config()[:lockfile], "..")
301+
end
299302
end
300303

301304
defp no_plt? do

test/dialyxir/project_test.exs

+10
Original file line numberDiff line numberDiff line change
@@ -184,4 +184,14 @@ defmodule Dialyxir.ProjectTest do
184184
assert Project.list_unused_filters?(list_unused_filters: nil)
185185
end)
186186
end
187+
188+
test "no_umbrella? works as expected" do
189+
in_project(:umbrella, fn ->
190+
refute Project.no_umbrella?()
191+
end)
192+
193+
in_project(:no_umbrella, fn ->
194+
assert Project.no_umbrella?()
195+
end)
196+
end
187197
end

test/fixtures/no_umbrella/mix.exs

+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
defmodule NoUmbrella.Mixfile do
2+
use Mix.Project
3+
4+
def project do
5+
[
6+
app: :no_umbrella,
7+
version: "0.1.0",
8+
lockfile: "../mix.lock",
9+
elixir: "~> 1.3",
10+
build_embedded: Mix.env() == :prod,
11+
start_permanent: Mix.env() == :prod,
12+
deps: [],
13+
dialyzer: [no_umbrella: true]
14+
]
15+
end
16+
17+
# Configuration for the OTP application
18+
#
19+
# Type "mix help compile.app" for more information
20+
def application do
21+
[applications: [:logger, :public_key]]
22+
end
23+
end

0 commit comments

Comments
 (0)