Fix elixir/dialyzer warnings

This commit is contained in:
Shadowfacts 2020-04-26 22:57:47 -04:00
parent 3caab0d808
commit 5d45f170f1
Signed by: shadowfacts
GPG Key ID: 94A5AB95422746E5
12 changed files with 25 additions and 23 deletions

View File

@ -113,7 +113,7 @@ defmodule Clacks.ActivityPub do
@spec follow(
actor :: String.t(),
followee :: String.t(),
published :: NaiveDateTime.t(),
published :: DateTime.t(),
state :: String.t()
) ::
map()

View File

@ -1,6 +1,6 @@
defmodule ClacksWeb.ActivitiesController do
use ClacksWeb, :controller
alias Clacks.{ActivityPub, Activity}
alias Clacks.Activity
alias ClacksWeb.Router.Helpers, as: Routes
alias ClacksWeb.Endpoint

View File

@ -40,7 +40,7 @@ defmodule ClacksWeb.FrontendController do
_ ->
# otherwise show local timeline
index(:local_timeline, conn)
index(:local_timeline, conn, params)
end
end
@ -251,12 +251,12 @@ defmodule ClacksWeb.FrontendController do
})
end
def post_status(conn, %{"content" => content} = params) do
def post_status(conn, %{"content" => _content} = params) do
current_user = conn.assigns[:user] |> Repo.preload(:actor)
note = note_for_posting(current_user, params)
note_changeset = Object.changeset_for_creating(note)
{:ok, object} = Repo.insert(note_changeset)
{:ok, _object} = Repo.insert(note_changeset)
create = ActivityPub.create(note)
{:ok, activity} = ActivityPub.Helper.save_and_federate(create, current_user.actor)
@ -306,7 +306,8 @@ defmodule ClacksWeb.FrontendController do
Repo.one(query)
end
@spec following_state(follower :: Actor.t(), followee :: Actor.t()) :: boolean()
@spec following_state(follower :: Actor.t(), followee :: Actor.t()) ::
:following | :not_following | :pending
defp following_state(follower, followee) do
case follow_activity(follower, followee) do
%Activity{data: %{"state" => "pending"}} ->

View File

@ -1,9 +1,8 @@
defmodule ClacksWeb.ObjectsController do
use ClacksWeb, :controller
alias Clacks.{Repo, Activity, Object, ActivityPub}
alias Clacks.{Activity, Object}
alias ClacksWeb.Router.Helpers, as: Routes
alias ClacksWeb.Endpoint
import Ecto.Query
def get(conn, params) do
case conn.assigns[:format] do

View File

@ -1,7 +1,6 @@
defmodule ClacksWeb.OutboxController do
use ClacksWeb, :controller
alias Clacks.{Repo, Actor, Activity, Timeline}
import Ecto.Query
alias Clacks.{Actor, Timeline}
@context "https://www.w3.org/ns/activitystreams"
@ -19,10 +18,10 @@ defmodule ClacksWeb.OutboxController do
end
end
def outbox(conn, params) when params == %{} do
def outbox(conn, %{} = params) do
actor = conn.assigns[:actor]
activities = Timeline.actor_timeline(actor, true, params)
activities = Timeline.actor_timeline(actor, params, true)
data = %{
"@context" => @context,
@ -39,7 +38,7 @@ defmodule ClacksWeb.OutboxController do
def outbox(conn, params) do
actor = conn.assigns[:actor]
activities = Timeline.actor_timeline(actor, true, params)
activities = Timeline.actor_timeline(actor, params, true)
data =
outbox_page(conn, params, activities)

View File

@ -8,7 +8,7 @@ defmodule ClacksWeb.Plug.WebAuthenticate do
when on_failure_action in [:redirect_to_login, :pass],
do: opts
def init(opts) do
def init(_opts) do
[on_failure: :redirect_to_login]
end

View File

@ -22,7 +22,7 @@
<% end %>
<% end %>
<%= if length(@status_results) do %>
<%= if length(@status_results) > 0 do %>
<hr>
<%= for {status, author} <- @status_results do %>

View File

@ -23,7 +23,7 @@
Logged in as <a href="<%= Routes.actor_path(@conn, :get, @user.username) %>"><%= @user.username %></a>.
</li>
<li>
<%= form_for @conn, Routes.login_path(@conn, :logout), [method: :post], fn f -> %>
<%= form_tag Routes.login_path(@conn, :logout), [method: :post] do %>
<%= submit "Log Out", class: "btn-link" %>
<% end %>
</li>

View File

@ -20,7 +20,7 @@ defmodule ClacksWeb.FrontendView do
def local_actor_link(%Actor{local: false, id: id}),
do: Routes.frontend_path(Endpoint, :actor, id)
@spec display_timestamp(str :: String.t()) :: String.t()
@spec display_timestamp(datetime :: String.t() | DateTime.t() | NaiveDateTime.t()) :: String.t()
def display_timestamp(str) when is_binary(str) do
display_timestamp(Timex.parse!(str, "{ISO:Extended}"))
@ -52,7 +52,7 @@ defmodule ClacksWeb.FrontendView do
end
@spec prev_page_path(conn :: Plug.Conn.t(), [Activity.t() | {Activity.t(), Actor.t()}]) ::
String.t()
String.t() | nil
def prev_page_path(conn, activities) do
if Map.has_key?(conn.query_params, "max_id") do
@ -65,7 +65,7 @@ defmodule ClacksWeb.FrontendView do
end
@spec next_page_path(conn :: Plug.Conn.t(), [Activity.t() | {Activity.t(), Actor.t()}]) ::
String.t()
String.t() | nil
def next_page_path(conn, activities) do
if length(activities) < 20 do

View File

@ -1,6 +1,6 @@
defmodule Mix.Tasks.Clacks.User do
use Mix.Task
alias Clacks.{Repo, User, Actor, Keys, ActivityPub}
alias Clacks.{Repo, User, Keys, ActivityPub}
@shortdoc "Creates a new user"
def run(["create"]) do
@ -41,7 +41,7 @@ defmodule Mix.Tasks.Clacks.User do
data: ActivityPub.actor(uri, username, username, public_key_pem)
})
{:ok, actor} = Repo.insert(actor)
{:ok, _actor} = Repo.insert(actor)
IO.puts("User #{username} successfully created")
end
@ -57,7 +57,7 @@ defmodule Mix.Tasks.Clacks.User do
changeset = User.change_password_changeset(user, %{password: password})
{:ok, user} = Repo.update(changeset)
{:ok, _user} = Repo.update(changeset)
IO.puts("Password updated")
end

View File

@ -51,7 +51,8 @@ defmodule Clacks.MixProject do
{:timex, "~> 3.6.1"},
{:bcrypt_elixir, "~> 2.0"},
{:oban, "~> 1.2.0"},
{:fast_sanitize, "~> 0.1.7"}
{:fast_sanitize, "~> 0.1.7"},
{:dialyxir, "~> 1.0", only: [:dev], runtime: false}
]
end

View File

@ -10,9 +10,11 @@
"custom_base": {:hex, :custom_base, "0.2.1", "4a832a42ea0552299d81652aa0b1f775d462175293e99dfbe4d7dbaab785a706", [:mix], [], "hexpm", "8df019facc5ec9603e94f7270f1ac73ddf339f56ade76a721eaa57c1493ba463"},
"db_connection": {:hex, :db_connection, "2.1.1", "a51e8a2ee54ef2ae6ec41a668c85787ed40cb8944928c191280fe34c15b76ae5", [:mix], [{:connection, "~> 1.0.2", [hex: :connection, repo: "hexpm", optional: false]}], "hexpm", "5a0e8c1c722dbcd31c0cbd1906b1d1074c863d335c295e4b994849b65a1fbe47"},
"decimal": {:hex, :decimal, "1.8.0", "ca462e0d885f09a1c5a342dbd7c1dcf27ea63548c65a65e67334f4b61803822e", [:mix], [], "hexpm", "52694ef56e60108e5012f8af9673874c66ed58ac1c4fae9b5b7ded31786663f5"},
"dialyxir": {:hex, :dialyxir, "1.0.0", "6a1fa629f7881a9f5aaf3a78f094b2a51a0357c843871b8bc98824e7342d00a5", [:mix], [{:erlex, ">= 0.2.6", [hex: :erlex, repo: "hexpm", optional: false]}], "hexpm", "aeb06588145fac14ca08d8061a142d52753dbc2cf7f0d00fc1013f53f8654654"},
"ecto": {:hex, :ecto, "3.2.1", "a0f9af0fb50b19d3bb6237e512ac0ba56ea222c2bbea92e7c6c94897932c76ba", [:mix], [{:decimal, "~> 1.6", [hex: :decimal, repo: "hexpm", optional: false]}, {:jason, "~> 1.0", [hex: :jason, repo: "hexpm", optional: true]}], "hexpm", "e1a1a1d72514b880d6bdd9fe9423d13a800ec1fb041c7239d885e5407b1fabce"},
"ecto_sql": {:hex, :ecto_sql, "3.2.0", "751cea597e8deb616084894dd75cbabfdbe7255ff01e8c058ca13f0353a3921b", [:mix], [{:db_connection, "~> 2.1", [hex: :db_connection, repo: "hexpm", optional: false]}, {:ecto, "~> 3.2.0", [hex: :ecto, repo: "hexpm", optional: false]}, {:myxql, "~> 0.2.0", [hex: :myxql, repo: "hexpm", optional: true]}, {:postgrex, "~> 0.15.0", [hex: :postgrex, repo: "hexpm", optional: true]}, {:telemetry, "~> 0.4.0", [hex: :telemetry, repo: "hexpm", optional: false]}], "hexpm", "a2e23cf761668126252418cae07eff7967ad0152fbc5e2d0dc3de487a5ec774c"},
"elixir_make": {:hex, :elixir_make, "0.6.0", "38349f3e29aff4864352084fc736fa7fa0f2995a819a737554f7ebd28b85aaab", [:mix], [], "hexpm", "d522695b93b7f0b4c0fcb2dfe73a6b905b1c301226a5a55cb42e5b14d509e050"},
"erlex": {:hex, :erlex, "0.2.6", "c7987d15e899c7a2f34f5420d2a2ea0d659682c06ac607572df55a43753aa12e", [:mix], [], "hexpm", "2ed2e25711feb44d52b17d2780eabf998452f6efda104877a3881c2f8c0c0c75"},
"fast_html": {:hex, :fast_html, "1.0.3", "2cc0d4b68496266a1530e0c852cafeaede0bd10cfdee26fda50dc696c203162f", [:make, :mix], [], "hexpm", "ab3d782b639d3c4655fbaec0f9d032c91f8cab8dd791ac7469c2381bc7c32f85"},
"fast_sanitize": {:hex, :fast_sanitize, "0.1.7", "2a7cd8734c88a2de6de55022104f8a3b87f1fdbe8bbf131d9049764b53d50d0d", [:mix], [{:fast_html, "~> 1.0", [hex: :fast_html, repo: "hexpm", optional: false]}, {:plug, "~> 1.8", [hex: :plug, repo: "hexpm", optional: false]}], "hexpm", "f39fe8ea08fbac17487c30bf09b7d9f3e12472e51fb07a88ffeb8fd17da8ab67"},
"file_system": {:hex, :file_system, "0.2.7", "e6f7f155970975789f26e77b8b8d8ab084c59844d8ecfaf58cbda31c494d14aa", [:mix], [], "hexpm", "b4cfa2d69c7f0b18fd06db222b2398abeef743a72504e6bd7df9c52f171b047f"},