Skip to content

Commit 5a3a85a

Browse files
author
José Valim
committed
Remove new line after "Found at" and enforce one mode
1 parent 911d786 commit 5a3a85a

File tree

2 files changed

+8
-8
lines changed

2 files changed

+8
-8
lines changed

lib/mix/lib/mix/tasks/xref.ex

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -48,13 +48,15 @@ defmodule Mix.Tasks.Xref do
4848
Mix.Task.run("compile")
4949
end
5050

51-
cond do
52-
opts[:warnings] ->
51+
mode = Keyword.take(opts, [:warnings, :unreachable])
52+
53+
case mode do
54+
[warnings: true] ->
5355
warnings()
54-
opts[:unreachable] ->
56+
[unreachable: true] ->
5557
unreachable()
56-
true ->
57-
Mix.raise "xref expects one of the following flags: --warnings, --unreachable"
58+
_ ->
59+
Mix.raise "xref expects exactly one of the following modes: --warnings, --unreachable"
5860
end
5961
end
6062

@@ -150,7 +152,7 @@ defmodule Mix.Tasks.Xref do
150152
end
151153

152154
defp format_file_lines(file, lines) do
153-
["\nFound at #{length(lines)} locations:\n" |
155+
["Found at #{length(lines)} locations:\n" |
154156
Enum.map(lines, &format_file_line(file, &1))]
155157
end
156158

lib/mix/test/mix/tasks/xref_test.exs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -146,13 +146,11 @@ defmodule Mix.Tasks.XrefTest do
146146
end
147147
""", """
148148
warning: function A.no_func/0 is undefined or private
149-
150149
Found at 2 locations:
151150
lib/a.ex:2
152151
lib/a.ex:4
153152
154153
warning: function A2.no_func/0 is undefined (module A2 is not available)
155-
156154
Found at 2 locations:
157155
lib/a.ex:3
158156
lib/a.ex:5

0 commit comments

Comments
 (0)