Add dialyzer

pull/2/head
Doc Ritezel 7 years ago
parent 630d811159
commit 5c304fa592
  1. 2
      .dialyzer-ignore
  2. 2
      circle.yml
  3. 4
      lib/explorer/fetcher.ex
  4. 1
      lib/explorer/latest_block.ex
  5. 1
      lib/explorer/repo.ex
  6. 2
      lib/explorer/scheduler.ex
  7. 2
      lib/explorer/transaction.ex
  8. 6
      lib/explorer_web/gettext.ex
  9. 1
      lib/explorer_web/views/page_view.ex
  10. 3
      lib/mix/tasks/scrape.ex
  11. 10
      mix.exs
  12. 1
      mix.lock
  13. 3
      test/support/conn_case.ex
  14. 1
      test/support/factory.ex

@ -0,0 +1,2 @@
:0: Unknown function 'Elixir.ExUnit.Callbacks':'__merge__'/3
:0: Unknown function 'Elixir.ExUnit.CaseTemplate':'__proxy__'/2

@ -33,6 +33,7 @@ dependencies:
timeout: 3600 timeout: 3600
override: override:
- yes | mix do deps.get, local.rebar, deps.compile, compile - yes | mix do deps.get, local.rebar, deps.compile, compile
- mix dialyzer --plt
- cd assets && npm install && cd .. - cd assets && npm install && cd ..
cache_directories: cache_directories:
- ~/.asdf - ~/.asdf
@ -44,6 +45,7 @@ test:
pre: pre:
- mix credo - mix credo
- mix sobelow --private --compact --exit Low - mix sobelow --private --compact --exit Low
- mix dialyzer --halt-exit-status
- cd assets && npm run eslint -- --format=junit --output-file="$CIRCLE_TEST_REPORTS/eslint/junit.xml" && cd .. - cd assets && npm run eslint -- --format=junit --output-file="$CIRCLE_TEST_REPORTS/eslint/junit.xml" && cd ..
override: override:
- mix test - mix test

@ -5,14 +5,16 @@ defmodule Explorer.Fetcher do
@moduledoc false @moduledoc false
@dialyzer {:nowarn_function, fetch: 1}
def fetch(block_number) do def fetch(block_number) do
block_number block_number
|> download_block |> download_block
|> extract_block |> extract_block
|> validate_block |> validate_block
|> Repo.insert |> Repo.insert!
end end
@dialyzer {:nowarn_function, download_block: 1}
def download_block(block_number) do def download_block(block_number) do
{:ok, block} = eth_get_block_by_number(block_number, true) {:ok, block} = eth_get_block_by_number(block_number, true)
block block

@ -4,6 +4,7 @@ defmodule Explorer.LatestBlock do
@moduledoc false @moduledoc false
@dialyzer {:nowarn_function, fetch: 0}
def fetch do def fetch do
get_latest_block() |> Fetcher.fetch get_latest_block() |> Fetcher.fetch
end end

@ -1,5 +1,6 @@
defmodule Explorer.Repo do defmodule Explorer.Repo do
use Ecto.Repo, otp_app: :explorer use Ecto.Repo, otp_app: :explorer
@dialyzer {:nowarn_function, rollback: 1}
@doc """ @doc """
Dynamically loads the repository url from the Dynamically loads the repository url from the

@ -1,4 +1,4 @@
defmodule Explorer.Scheduler do defmodule Explorer.Scheduler do
use Quantum.Scheduler, otp_app: :explorer
@moduledoc false @moduledoc false
use Quantum.Scheduler, otp_app: :explorer
end end

@ -20,7 +20,7 @@ defmodule Explorer.Transaction do
@optional_attrs ~w()a @optional_attrs ~w()a
@doc false @doc false
def changeset(%Transaction{} = transaction, attrs \\ :empty) do def changeset(%Transaction{} = transaction, attrs \\ %{}) do
transaction transaction
|> cast(attrs, [:block_id | @required_attrs], @optional_attrs) |> cast(attrs, [:block_id | @required_attrs], @optional_attrs)
|> validate_required(@required_attrs) |> validate_required(@required_attrs)

@ -21,4 +21,10 @@ defmodule ExplorerWeb.Gettext do
See the [Gettext Docs](https://hexdocs.pm/gettext) for detailed usage. See the [Gettext Docs](https://hexdocs.pm/gettext) for detailed usage.
""" """
use Gettext, otp_app: :explorer use Gettext, otp_app: :explorer
@dialyzer [{:nowarn_function, 'MACRO-dgettext': 3},
{:nowarn_function, 'MACRO-dgettext': 4},
{:nowarn_function, 'MACRO-dngettext': 5},
{:nowarn_function, 'MACRO-dngettext': 6},
]
end end

@ -1,3 +1,4 @@
defmodule ExplorerWeb.PageView do defmodule ExplorerWeb.PageView do
use ExplorerWeb, :view use ExplorerWeb, :view
@dialyzer :no_match
end end

@ -5,8 +5,9 @@ defmodule Mix.Tasks.Scrape do
@shortdoc "Scrape the blockchain." @shortdoc "Scrape the blockchain."
@moduledoc false @moduledoc false
@dialyzer {:nowarn_function, run: 1}
def run(_) do def run(_) do
Mix.Task.run "app.start" Mix.Task.run("app.start")
LatestBlock.fetch() LatestBlock.fetch()
end end
end end

@ -7,10 +7,15 @@ defmodule Explorer.Mixfile do
version: "0.0.1", version: "0.0.1",
elixir: "~> 1.4", elixir: "~> 1.4",
elixirc_paths: elixirc_paths(Mix.env), elixirc_paths: elixirc_paths(Mix.env),
compilers: [:phoenix, :gettext] ++ Mix.compilers, compilers: [:phoenix, :gettext | Mix.compilers],
start_permanent: Mix.env == :prod, start_permanent: Mix.env == :prod,
aliases: aliases(), aliases: aliases(),
deps: deps() deps: deps(),
dialyzer: [
plt_add_deps: :transitive,
plt_add_apps: [:mix],
ignore_warnings: ".dialyzer-ignore"
]
] ]
end end
@ -41,6 +46,7 @@ defmodule Explorer.Mixfile do
[ [
{:cowboy, "~> 1.0"}, {:cowboy, "~> 1.0"},
{:credo, "~> 0.8", only: [:dev, :test], runtime: false}, {:credo, "~> 0.8", only: [:dev, :test], runtime: false},
{:dialyxir, "~> 0.5", only: [:dev, :test], runtime: false},
{:ethereumex, github: "exthereum/ethereumex", commit: "262f1d81ae163ffb46e127283658249dac1c8318"}, # Waiting for this version to be pushed to Hex. {:ethereumex, github: "exthereum/ethereumex", commit: "262f1d81ae163ffb46e127283658249dac1c8318"}, # Waiting for this version to be pushed to Hex.
{:ex_machina, "~> 2.1", only: [:test]}, {:ex_machina, "~> 2.1", only: [:test]},
{:exvcr, "~> 0.8", only: :test}, {:exvcr, "~> 0.8", only: :test},

@ -8,6 +8,7 @@
"crontab": {:hex, :crontab, "1.1.2", "4784a50987b4a19af07a908f98e8a308b00f9c93efc5a7892155dc10cd8fc7d9", [:mix], [{:ecto, "~> 1.0 or ~> 2.0 or ~> 2.1", [hex: :ecto, repo: "hexpm", optional: true]}], "hexpm"}, "crontab": {:hex, :crontab, "1.1.2", "4784a50987b4a19af07a908f98e8a308b00f9c93efc5a7892155dc10cd8fc7d9", [:mix], [{:ecto, "~> 1.0 or ~> 2.0 or ~> 2.1", [hex: :ecto, repo: "hexpm", optional: true]}], "hexpm"},
"db_connection": {:hex, :db_connection, "1.1.3", "89b30ca1ef0a3b469b1c779579590688561d586694a3ce8792985d4d7e575a61", [:mix], [{:connection, "~> 1.0.2", [hex: :connection, repo: "hexpm", optional: false]}, {:poolboy, "~> 1.5", [hex: :poolboy, repo: "hexpm", optional: true]}, {:sbroker, "~> 1.0", [hex: :sbroker, repo: "hexpm", optional: true]}], "hexpm"}, "db_connection": {:hex, :db_connection, "1.1.3", "89b30ca1ef0a3b469b1c779579590688561d586694a3ce8792985d4d7e575a61", [:mix], [{:connection, "~> 1.0.2", [hex: :connection, repo: "hexpm", optional: false]}, {:poolboy, "~> 1.5", [hex: :poolboy, repo: "hexpm", optional: true]}, {:sbroker, "~> 1.0", [hex: :sbroker, repo: "hexpm", optional: true]}], "hexpm"},
"decimal": {:hex, :decimal, "1.4.1", "ad9e501edf7322f122f7fc151cce7c2a0c9ada96f2b0155b8a09a795c2029770", [:mix], [], "hexpm"}, "decimal": {:hex, :decimal, "1.4.1", "ad9e501edf7322f122f7fc151cce7c2a0c9ada96f2b0155b8a09a795c2029770", [:mix], [], "hexpm"},
"dialyxir": {:hex, :dialyxir, "0.5.1", "b331b091720fd93e878137add264bac4f644e1ddae07a70bf7062c7862c4b952", [:mix], [], "hexpm"},
"ecto": {:hex, :ecto, "2.2.8", "a4463c0928b970f2cee722cd29aaac154e866a15882c5737e0038bbfcf03ec2c", [:mix], [{:db_connection, "~> 1.1", [hex: :db_connection, repo: "hexpm", optional: true]}, {:decimal, "~> 1.2", [hex: :decimal, repo: "hexpm", optional: false]}, {:mariaex, "~> 0.8.0", [hex: :mariaex, repo: "hexpm", optional: true]}, {:poison, "~> 2.2 or ~> 3.0", [hex: :poison, repo: "hexpm", optional: true]}, {:poolboy, "~> 1.5", [hex: :poolboy, repo: "hexpm", optional: false]}, {:postgrex, "~> 0.13.0", [hex: :postgrex, repo: "hexpm", optional: true]}, {:sbroker, "~> 1.0", [hex: :sbroker, repo: "hexpm", optional: true]}], "hexpm"}, "ecto": {:hex, :ecto, "2.2.8", "a4463c0928b970f2cee722cd29aaac154e866a15882c5737e0038bbfcf03ec2c", [:mix], [{:db_connection, "~> 1.1", [hex: :db_connection, repo: "hexpm", optional: true]}, {:decimal, "~> 1.2", [hex: :decimal, repo: "hexpm", optional: false]}, {:mariaex, "~> 0.8.0", [hex: :mariaex, repo: "hexpm", optional: true]}, {:poison, "~> 2.2 or ~> 3.0", [hex: :poison, repo: "hexpm", optional: true]}, {:poolboy, "~> 1.5", [hex: :poolboy, repo: "hexpm", optional: false]}, {:postgrex, "~> 0.13.0", [hex: :postgrex, repo: "hexpm", optional: true]}, {:sbroker, "~> 1.0", [hex: :sbroker, repo: "hexpm", optional: true]}], "hexpm"},
"ethereumex": {:git, "https://github.com/exthereum/ethereumex.git", "262f1d81ae163ffb46e127283658249dac1c8318", []}, "ethereumex": {:git, "https://github.com/exthereum/ethereumex.git", "262f1d81ae163ffb46e127283658249dac1c8318", []},
"ex_machina": {:hex, :ex_machina, "2.1.0", "4874dc9c78e7cf2d429f24dc3c4005674d4e4da6a08be961ffccc08fb528e28b", [:mix], [{:ecto, "~> 2.1", [hex: :ecto, repo: "hexpm", optional: true]}], "hexpm"}, "ex_machina": {:hex, :ex_machina, "2.1.0", "4874dc9c78e7cf2d429f24dc3c4005674d4e4da6a08be961ffccc08fb528e28b", [:mix], [{:ecto, "~> 2.1", [hex: :ecto, repo: "hexpm", optional: true]}], "hexpm"},

@ -28,7 +28,7 @@ defmodule ExplorerWeb.ConnCase do
end end
end end
@dialyzer {:nowarn_function, __ex_unit_setup_0: 1}
setup tags do setup tags do
:ok = Ecto.Adapters.SQL.Sandbox.checkout(Explorer.Repo) :ok = Ecto.Adapters.SQL.Sandbox.checkout(Explorer.Repo)
unless tags[:async] do unless tags[:async] do
@ -36,5 +36,4 @@ defmodule ExplorerWeb.ConnCase do
end end
{:ok, conn: Phoenix.ConnTest.build_conn()} {:ok, conn: Phoenix.ConnTest.build_conn()}
end end
end end

@ -1,4 +1,5 @@
defmodule Explorer.Factory do defmodule Explorer.Factory do
@dialyzer {:nowarn_function, fields_for: 1}
use ExMachina.Ecto, repo: Explorer.Repo use ExMachina.Ecto, repo: Explorer.Repo
use Explorer.BlockFactory use Explorer.BlockFactory
use Explorer.TransactionFactory use Explorer.TransactionFactory

Loading…
Cancel
Save