Skip to content

Commit bb08b41

Browse files
author
José Valim
committed
Add mix xref deprecated
1 parent dbfab69 commit bb08b41

File tree

7 files changed

+291
-215
lines changed

7 files changed

+291
-215
lines changed

lib/elixir/lib/module.ex

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,9 @@ defmodule Module do
115115
end
116116
end
117117
118+
The mix compiler automatically looks for calls to deprecated modules
119+
and emit warnings during compilation, computed via `mix xref warnings`.
120+
118121
### `@doc` (and `@since`)
119122
120123
Provides documentation for the function or macro that follows the

lib/mix/lib/mix/tasks/compile.protocols.ex

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,9 +40,13 @@ defmodule Mix.Tasks.Compile.Protocols do
4040
true
4141
4242
"""
43+
44+
@doc """
45+
Runs this task.
46+
"""
4347
def run(args) do
4448
config = Mix.Project.config()
45-
Mix.Task.run("compile", args)
49+
Mix.Task.run("compile")
4650
{opts, _, _} = OptionParser.parse(args, switches: [force: :boolean, verbose: :boolean])
4751

4852
manifest = manifest()

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

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,15 @@ defmodule Mix.Tasks.Compile.Xref do
99
@moduledoc """
1010
Performs remote dispatch checking.
1111
12-
When this task runs, it will check the modification time of the `:elixir`
13-
compiler manifest. If it has changed, `mix xref` will be run to check remote
14-
dispatches. You can force checking regardless of modification time by passing
15-
the `--force` option.
12+
It uses `mix xref` to check if any remote call does not exist or is
13+
deprecated, and emits a warnings in such cases. This tasks does not show
14+
deprecated local calls (a call to a deprecated function or macro in the
15+
same module) nor calls to deprecated functionality in Elixir itself.
16+
17+
When this task runs, it will check if the source code has been modified.
18+
If it has changed, `mix xref` will be run to check remote dispatches. You
19+
can force checking regardless of modification time by passing the `--force`
20+
option.
1621
1722
## Command line options
1823
@@ -28,6 +33,8 @@ defmodule Mix.Tasks.Compile.Xref do
2833
{opts, _, _} =
2934
OptionParser.parse(args, switches: [force: :boolean, warnings_as_errors: :boolean])
3035

36+
Mix.Task.run("compile")
37+
3138
warnings =
3239
if needs_xref?(opts) do
3340
run_xref()
@@ -48,15 +55,9 @@ defmodule Mix.Tasks.Compile.Xref do
4855

4956
defp run_xref do
5057
timestamp = :calendar.universal_time()
51-
52-
case Mix.Task.run("xref", ["warnings"]) do
53-
:noop ->
54-
[]
55-
56-
{:ok, warnings} ->
57-
write_manifest(warnings, timestamp)
58-
warnings
59-
end
58+
warnings = Mix.Tasks.Xref.warnings([])
59+
write_manifest(warnings, timestamp)
60+
warnings
6061
end
6162

6263
defp warnings_as_errors(opts) do

0 commit comments

Comments
 (0)