From 70d8297aabc040dcc99b63dbc214ec8fb6db63aa Mon Sep 17 00:00:00 2001 From: Viktor Baranov Date: Wed, 9 Mar 2022 18:04:21 +0300 Subject: [PATCH] Bump credo from 1.5.6 to 1.6.4 --- .../views/api/rpc/token_view.ex | 4 ++++ .../views/bridged_tokens_view.ex | 2 +- .../views/smart_contract_view.ex | 18 ++++++------------ .../block_scout_web/views/transaction_view.ex | 2 +- .../lib/ethereum_jsonrpc/encoder.ex | 4 ++-- .../lib/ethereum_jsonrpc/web_socket.ex | 2 +- apps/explorer/lib/explorer/chain.ex | 6 ++---- .../lib/explorer/chain/address/token.ex | 2 +- apps/explorer/lib/explorer/chain/import.ex | 2 +- .../lib/explorer/chain/token_transfer.ex | 2 +- .../lib/explorer/chain_spec/genesis_data.ex | 5 ++--- .../lib/explorer/staking/contract_reader.ex | 6 ++---- apps/indexer/lib/indexer/block/fetcher.ex | 2 +- mix.lock | 2 +- 14 files changed, 26 insertions(+), 33 deletions(-) diff --git a/apps/block_scout_web/lib/block_scout_web/views/api/rpc/token_view.ex b/apps/block_scout_web/lib/block_scout_web/views/api/rpc/token_view.ex index 449759827c..4fb387bf7f 100644 --- a/apps/block_scout_web/lib/block_scout_web/views/api/rpc/token_view.ex +++ b/apps/block_scout_web/lib/block_scout_web/views/api/rpc/token_view.ex @@ -41,6 +41,10 @@ defmodule BlockScoutWeb.API.RPC.TokenView do } end + defp prepare_bridged_token([]) do + %{} + end + defp prepare_bridged_token([token, bridged_token]) do total_supply = divide_decimals(token.total_supply, token.decimals) usd_value = BridgedTokensView.bridged_token_usd_cap(bridged_token, token) diff --git a/apps/block_scout_web/lib/block_scout_web/views/bridged_tokens_view.ex b/apps/block_scout_web/lib/block_scout_web/views/bridged_tokens_view.ex index f59617ff41..0b2440522e 100644 --- a/apps/block_scout_web/lib/block_scout_web/views/bridged_tokens_view.ex +++ b/apps/block_scout_web/lib/block_scout_web/views/bridged_tokens_view.ex @@ -34,7 +34,7 @@ defmodule BlockScoutWeb.BridgedTokensView do @doc """ Calculates capitalization of the bridged token in USD. """ - @spec bridged_token_usd_cap(%BridgedToken{}, %Token{}) :: any() + @spec bridged_token_usd_cap(BridgedToken.t(), Token.t()) :: any() def bridged_token_usd_cap(bridged_token, token) do if bridged_token.custom_cap do bridged_token.custom_cap diff --git a/apps/block_scout_web/lib/block_scout_web/views/smart_contract_view.ex b/apps/block_scout_web/lib/block_scout_web/views/smart_contract_view.ex index 67524a2d06..b7660e4e5c 100644 --- a/apps/block_scout_web/lib/block_scout_web/views/smart_contract_view.ex +++ b/apps/block_scout_web/lib/block_scout_web/views/smart_contract_view.ex @@ -65,16 +65,14 @@ defmodule BlockScoutWeb.SmartContractView do String.starts_with?(type, "address") -> values = value - |> Enum.map(&binary_to_utf_string(&1)) - |> Enum.join(", ") + |> Enum.map_join(", ", &binary_to_utf_string(&1)) render_array_type_value(type, values, fetch_name(names, index)) String.starts_with?(type, "bytes") -> values = value - |> Enum.map(&binary_to_utf_string(&1)) - |> Enum.join(", ") + |> Enum.map_join(", ", &binary_to_utf_string(&1)) render_array_type_value(type, values, fetch_name(names, index)) @@ -149,8 +147,7 @@ defmodule BlockScoutWeb.SmartContractView do values = value |> Enum.map(&values_only(&1, String.slice(type, 0..-3), components, nested_index + 1)) - |> Enum.map(&(String.duplicate(@tab, nested_index) <> &1)) - |> Enum.join(",
") + |> Enum.map_join(",
", &(String.duplicate(@tab, nested_index) <> &1)) wrap_output(render_nested_array_value(values, nested_index - 1), is_too_long) @@ -170,16 +167,14 @@ defmodule BlockScoutWeb.SmartContractView do String.starts_with?(type, "address") -> values = value - |> Enum.map(&binary_to_utf_string(&1)) - |> Enum.join(", ") + |> Enum.map_join(", ", &binary_to_utf_string(&1)) wrap_output(render_array_value(values), is_too_long) String.starts_with?(type, "bytes") -> values = value - |> Enum.map(&binary_to_utf_string(&1)) - |> Enum.join(", ") + |> Enum.map_join(", ", &binary_to_utf_string(&1)) wrap_output(render_array_value(values), is_too_long) @@ -355,10 +350,9 @@ defmodule BlockScoutWeb.SmartContractView do if type == "tuple" && components do types = components - |> Enum.map(fn component -> + |> Enum.map_join(",", fn component -> Map.get(component, "type") end) - |> Enum.join(",") "tuple[" <> types <> "]" else diff --git a/apps/block_scout_web/lib/block_scout_web/views/transaction_view.ex b/apps/block_scout_web/lib/block_scout_web/views/transaction_view.ex index ab2be5a31e..2f0d829d96 100644 --- a/apps/block_scout_web/lib/block_scout_web/views/transaction_view.ex +++ b/apps/block_scout_web/lib/block_scout_web/views/transaction_view.ex @@ -567,7 +567,7 @@ defmodule BlockScoutWeb.TransactionView do end # Function decodes revert reason of the transaction - @spec decoded_revert_reason(%Transaction{} | nil) :: binary() | nil + @spec decoded_revert_reason(Transaction.t() | nil) :: binary() | nil def decoded_revert_reason(transaction) do revert_reason = get_pure_transaction_revert_reason(transaction) diff --git a/apps/ethereum_jsonrpc/lib/ethereum_jsonrpc/encoder.ex b/apps/ethereum_jsonrpc/lib/ethereum_jsonrpc/encoder.ex index eae2cceb1b..034c12de67 100644 --- a/apps/ethereum_jsonrpc/lib/ethereum_jsonrpc/encoder.ex +++ b/apps/ethereum_jsonrpc/lib/ethereum_jsonrpc/encoder.ex @@ -11,7 +11,7 @@ defmodule EthereumJSONRPC.Encoder do This is what is expected on the Json RPC data parameter. """ - @spec encode_function_call(%ABI.FunctionSelector{}, [term()]) :: String.t() + @spec encode_function_call(ABI.FunctionSelector.t(), [term()]) :: String.t() def encode_function_call(function_selector, args) do parsed_args = parse_args(args) @@ -49,7 +49,7 @@ defmodule EthereumJSONRPC.Encoder do """ def decode_result(_, _, leave_error_as_map \\ false) - @spec decode_result(map(), %ABI.FunctionSelector{} | [%ABI.FunctionSelector{}]) :: + @spec decode_result(map(), ABI.FunctionSelector.t() | [ABI.FunctionSelector.t()]) :: {String.t(), {:ok, any()} | {:error, String.t() | :invalid_data}} def decode_result(%{error: %{code: code, data: data, message: message}, id: id}, _selector, leave_error_as_map) do if leave_error_as_map do diff --git a/apps/ethereum_jsonrpc/lib/ethereum_jsonrpc/web_socket.ex b/apps/ethereum_jsonrpc/lib/ethereum_jsonrpc/web_socket.ex index bdad4ea131..43c8906032 100644 --- a/apps/ethereum_jsonrpc/lib/ethereum_jsonrpc/web_socket.ex +++ b/apps/ethereum_jsonrpc/lib/ethereum_jsonrpc/web_socket.ex @@ -103,7 +103,7 @@ defmodule EthereumJSONRPC.WebSocket do end @impl Transport - @spec unsubscribe(%Subscription{transport: __MODULE__, transport_options: t()}) :: :ok | {:error, reason :: term()} + @spec unsubscribe(Subscription.t()) :: :ok | {:error, reason :: term()} def unsubscribe( %Subscription{ transport: __MODULE__, diff --git a/apps/explorer/lib/explorer/chain.ex b/apps/explorer/lib/explorer/chain.ex index 14aa496a01..c9788ae59a 100644 --- a/apps/explorer/lib/explorer/chain.ex +++ b/apps/explorer/lib/explorer/chain.ex @@ -1115,7 +1115,7 @@ defmodule Explorer.Chain do {:actual, Decimal.new(4)} """ - @spec fee(%Transaction{gas_used: nil}, :ether | :gwei | :wei) :: {:maximum, Decimal.t()} + @spec fee(Transaction.t(), :ether | :gwei | :wei) :: {:maximum, Decimal.t()} | {:actual, Decimal.t()} def fee(%Transaction{gas: gas, gas_price: gas_price, gas_used: nil}, unit) do fee = gas_price @@ -1125,7 +1125,6 @@ defmodule Explorer.Chain do {:maximum, fee} end - @spec fee(%Transaction{gas_used: Decimal.t()}, :ether | :gwei | :wei) :: {:actual, Decimal.t()} def fee(%Transaction{gas_price: gas_price, gas_used: gas_used}, unit) do fee = gas_price @@ -1305,8 +1304,7 @@ defmodule Explorer.Chain do [_ | _] = words -> term_final = words - |> Enum.map(fn [word] -> word <> ":*" end) - |> Enum.join(" & ") + |> Enum.map_join(" & ", fn [word] -> word <> ":*" end) {:some, term_final} diff --git a/apps/explorer/lib/explorer/chain/address/token.ex b/apps/explorer/lib/explorer/chain/address/token.ex index b2bfabeaf2..69930d3a7e 100644 --- a/apps/explorer/lib/explorer/chain/address/token.ex +++ b/apps/explorer/lib/explorer/chain/address/token.ex @@ -28,7 +28,7 @@ defmodule Explorer.Chain.Address.Token do @doc """ It builds a paginated query of Address.Tokens that have a balance higher than zero ordered by type and name. """ - @spec list_address_tokens_with_balance(Hash.t(), [paging_options()]) :: %Ecto.Query{} + @spec list_address_tokens_with_balance(Hash.t(), [paging_options()]) :: Ecto.Query.t() def list_address_tokens_with_balance(address_hash, options \\ []) do paging_options = Keyword.get(options, :paging_options, @default_paging_options) diff --git a/apps/explorer/lib/explorer/chain/import.ex b/apps/explorer/lib/explorer/chain/import.ex index 3fad48ba6b..b3aa19ac42 100644 --- a/apps/explorer/lib/explorer/chain/import.ex +++ b/apps/explorer/lib/explorer/chain/import.ex @@ -231,7 +231,7 @@ defmodule Explorer.Chain.Import do runner_specific_options = if Map.has_key?(Enum.into(runner.__info__(:functions), %{}), :runner_specific_options) do - apply(runner, :runner_specific_options, []) + runner.runner_specific_options() else [] end diff --git a/apps/explorer/lib/explorer/chain/token_transfer.ex b/apps/explorer/lib/explorer/chain/token_transfer.ex index 6a8022db35..2eb7af5f16 100644 --- a/apps/explorer/lib/explorer/chain/token_transfer.ex +++ b/apps/explorer/lib/explorer/chain/token_transfer.ex @@ -307,7 +307,7 @@ defmodule Explorer.Chain.TokenTransfer do To find out its current owner, it is necessary to look at the token last transfer. """ - @spec address_to_unique_tokens(Hash.Address.t()) :: %Ecto.Query{} + @spec address_to_unique_tokens(Hash.Address.t()) :: Ecto.Query.t() def address_to_unique_tokens(contract_address_hash) do from( tt in TokenTransfer, diff --git a/apps/explorer/lib/explorer/chain_spec/genesis_data.ex b/apps/explorer/lib/explorer/chain_spec/genesis_data.ex index 02fd01c4b8..a67036fa42 100644 --- a/apps/explorer/lib/explorer/chain_spec/genesis_data.ex +++ b/apps/explorer/lib/explorer/chain_spec/genesis_data.ex @@ -97,9 +97,8 @@ defmodule Explorer.ChainSpec.GenesisData do # sobelow_skip ["Traversal"] defp fetch_from_file(path) do - with {:ok, data} <- File.read(path), - {:ok, json} <- Jason.decode(data) do - {:ok, json} + with {:ok, data} <- File.read(path) do + Jason.decode(data) end end diff --git a/apps/explorer/lib/explorer/staking/contract_reader.ex b/apps/explorer/lib/explorer/staking/contract_reader.ex index af1984d79a..1bce804e11 100644 --- a/apps/explorer/lib/explorer/staking/contract_reader.ex +++ b/apps/explorer/lib/explorer/staking/contract_reader.ex @@ -191,12 +191,11 @@ defmodule Explorer.Staking.ContractReader do ) do staking_epochs_joint = staking_epochs - |> Enum.map(fn epoch -> + |> Enum.map_join(fn epoch -> epoch |> Integer.to_string(16) |> String.pad_leading(64, ["0"]) end) - |> Enum.join("") pool_staking_address = address_pad_to_64(pool_staking_address) staker = address_pad_to_64(staker) @@ -268,12 +267,11 @@ defmodule Explorer.Staking.ContractReader do ) do staking_epochs_joint = staking_epochs - |> Enum.map(fn epoch -> + |> Enum.map_join(fn epoch -> epoch |> Integer.to_string(16) |> String.pad_leading(64, ["0"]) end) - |> Enum.join("") pool_staking_address = address_pad_to_64(pool_staking_address) diff --git a/apps/indexer/lib/indexer/block/fetcher.ex b/apps/indexer/lib/indexer/block/fetcher.ex index 591e8bc9ed..3a5e537d42 100644 --- a/apps/indexer/lib/indexer/block/fetcher.ex +++ b/apps/indexer/lib/indexer/block/fetcher.ex @@ -110,7 +110,7 @@ defmodule Indexer.Block.Fetcher do @spec fetch_and_import_range(t, Range.t()) :: {:ok, %{inserted: %{}, errors: [EthereumJSONRPC.Transport.error()]}} | {:error, - {step :: atom(), reason :: [%Ecto.Changeset{}] | term()} + {step :: atom(), reason :: [Ecto.Changeset.t()] | term()} | {step :: atom(), failed_value :: term(), changes_so_far :: term()}} def fetch_and_import_range( %__MODULE__{ diff --git a/mix.lock b/mix.lock index 6db5232643..513b986f87 100644 --- a/mix.lock +++ b/mix.lock @@ -21,7 +21,7 @@ "cowboy": {:hex, :cowboy, "2.9.0", "865dd8b6607e14cf03282e10e934023a1bd8be6f6bacf921a7e2a96d800cd452", [:make, :rebar3], [{:cowlib, "2.11.0", [hex: :cowlib, repo: "hexpm", optional: false]}, {:ranch, "1.8.0", [hex: :ranch, repo: "hexpm", optional: false]}], "hexpm", "2c729f934b4e1aa149aff882f57c6372c15399a20d54f65c8d67bef583021bde"}, "cowboy_telemetry": {:hex, :cowboy_telemetry, "0.3.1", "ebd1a1d7aff97f27c66654e78ece187abdc646992714164380d8a041eda16754", [:rebar3], [{:cowboy, "~> 2.7", [hex: :cowboy, repo: "hexpm", optional: false]}, {:telemetry, "~> 0.4", [hex: :telemetry, repo: "hexpm", optional: false]}], "hexpm", "3a6efd3366130eab84ca372cbd4a7d3c3a97bdfcfb4911233b035d117063f0af"}, "cowlib": {:hex, :cowlib, "2.11.0", "0b9ff9c346629256c42ebe1eeb769a83c6cb771a6ee5960bd110ab0b9b872063", [:make, :rebar3], [], "hexpm", "2b3e9da0b21c4565751a6d4901c20d1b4cc25cbb7fd50d91d2ab6dd287bc86a9"}, - "credo": {:hex, :credo, "1.5.6", "e04cc0fdc236fefbb578e0c04bd01a471081616e741d386909e527ac146016c6", [:mix], [{:bunt, "~> 0.2.0", [hex: :bunt, repo: "hexpm", optional: false]}, {:file_system, "~> 0.2.8", [hex: :file_system, repo: "hexpm", optional: false]}, {:jason, "~> 1.0", [hex: :jason, repo: "hexpm", optional: false]}], "hexpm", "4b52a3e558bd64e30de62a648518a5ea2b6e3e5d2b164ef5296244753fc7eb17"}, + "credo": {:hex, :credo, "1.6.4", "ddd474afb6e8c240313f3a7b0d025cc3213f0d171879429bf8535d7021d9ad78", [:mix], [{:bunt, "~> 0.2.0", [hex: :bunt, repo: "hexpm", optional: false]}, {:file_system, "~> 0.2.8", [hex: :file_system, repo: "hexpm", optional: false]}, {:jason, "~> 1.0", [hex: :jason, repo: "hexpm", optional: false]}], "hexpm", "c28f910b61e1ff829bffa056ef7293a8db50e87f2c57a9b5c3f57eee124536b7"}, "csv": {:hex, :csv, "2.4.1", "50e32749953b6bf9818dbfed81cf1190e38cdf24f95891303108087486c5925e", [:mix], [{:parallel_stream, "~> 1.0.4", [hex: :parallel_stream, repo: "hexpm", optional: false]}], "hexpm", "54508938ac67e27966b10ef49606e3ad5995d665d7fc2688efb3eab1307c9079"}, "dataloader": {:hex, :dataloader, "1.0.9", "8fb981e327fa692f741ab283ed93790203a6f6d412800f0f4f1531372e1dbf15", [:mix], [{:ecto, ">= 3.4.3 and < 4.0.0", [hex: :ecto, repo: "hexpm", optional: true]}, {:telemetry, "~> 0.4", [hex: :telemetry, repo: "hexpm", optional: false]}], "hexpm", "6f8b7566c8dda46f53bdb336fd02f03f00bf58aeb6cc0f139ccdfd6f99d265a7"}, "db_connection": {:hex, :db_connection, "2.4.0", "d04b1b73795dae60cead94189f1b8a51cc9e1f911c234cc23074017c43c031e5", [:mix], [{:connection, "~> 1.0", [hex: :connection, repo: "hexpm", optional: false]}, {:telemetry, "~> 0.4 or ~> 1.0", [hex: :telemetry, repo: "hexpm", optional: false]}], "hexpm", "ad416c21ad9f61b3103d254a71b63696ecadb6a917b36f563921e0de00d7d7c8"},