Current section

Files

Jump to
archeometer lib mix tasks archeometer.explore.ex
Raw

lib/mix/tasks/archeometer.explore.ex

defmodule Mix.Tasks.Arch.Explore do
use Mix.Task
@moduledoc """
Mix task to gather information about the project and store it into the database.
It currently gathers information about:
- Inventory of applications, modules, functions and macros.
- Metrics related to them such as: size and complexity.
- Information about test coverage.
- Internal dependencies between modules.
Usage:
mix arch.explore [options]
The following options are accepted:
* `--no-coverage` avoid running tests and collecting coverage information
* `--include-deps` wildcard glob style to filter dependencies
"""
@shortdoc "Explore current project and stores info into Archeometer DB"
@impl Mix.Task
def run(argv) do
if Enum.member?(argv, "--no-coverage") do
argv
|> List.delete("--no-coverage")
|> explore_basic()
else
explore_basic(argv)
explore_coverage()
end
end
defp explore_basic(argv) do
if Mix.Task.run("arch.explore.static", argv) == :ok do
Mix.Task.run("arch.explore.xrefs", argv)
Mix.Task.run("arch.explore.apps", argv)
Mix.Task.run("arch.explore.ecto", argv)
else
Mix.shell().error("Error: Could not run static exploration")
end
end
defp explore_coverage do
# Coverage needs to be called as a command in order to set the mix testing environment
Mix.Shell.cmd("mix arch.explore.coverage", [env: %{"MIX_ENV" => "test"}], &IO.puts/1)
end
end