Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enable -Wunmatched_return in dialyzer #508

Merged
merged 1 commit into from
Jun 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions lib/mix/tasks/gh/docs.ex
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ defmodule Mix.Tasks.Gh.Docs do

# Taken from https://gist.github.com/jjh42/5737777 with some modifications
@shortdoc "Mix task to publish gh-pages site."
@dialyzer {:nowarn_function, run: 1}
def run(_) do
File.rm_rf("doc")
Mix.Task.run("docs")
Expand Down
2 changes: 1 addition & 1 deletion lib/nostrum/api.ex
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ defmodule Nostrum.Api do
"""
@spec update_status(status, String.t(), integer, String.t() | nil) :: :ok
def update_status(status, game, type \\ 0, stream \\ nil) do
Supervisor.update_status(to_string(status), game, stream, type)
_result = Supervisor.update_status(to_string(status), game, stream, type)
:ok
end

Expand Down
2 changes: 1 addition & 1 deletion lib/nostrum/cache/channel_guild_mapping/ets.ex
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ defmodule Nostrum.Cache.ChannelGuildMapping.ETS do
@doc "Set up the ETS table."
@impl Supervisor
def init(_init_arg) do
:ets.new(@table_name, [:set, :public, :named_table])
_tid = :ets.new(@table_name, [:set, :public, :named_table])
Supervisor.init([], strategy: :one_for_one)
end

Expand Down
2 changes: 1 addition & 1 deletion lib/nostrum/cache/guild_cache/ets.ex
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ defmodule Nostrum.Cache.GuildCache.ETS do
@doc "Set up the cache's ETS table."
@impl Supervisor
def init(_init_arg) do
:ets.new(tabname(), [:set, :public, :named_table])
_tid = :ets.new(tabname(), [:set, :public, :named_table])
Supervisor.init([], strategy: :one_for_one)
end

Expand Down
2 changes: 1 addition & 1 deletion lib/nostrum/cache/member_cache/ets.ex
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ defmodule Nostrum.Cache.MemberCache.ETS do
@doc "Set up the cache's ETS table."
@impl Supervisor
def init(_init_arg) do
:ets.new(@table_name, [:set, :public, :named_table])
_tid = :ets.new(@table_name, [:set, :public, :named_table])
Supervisor.init([], strategy: :one_for_one)
end

Expand Down
2 changes: 1 addition & 1 deletion lib/nostrum/cache/presence_cache/ets.ex
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ defmodule Nostrum.Cache.PresenceCache.ETS do
@doc "Set up the cache's ETS table."
@impl Supervisor
def init(_init_arg) do
:ets.new(@table_name, [:set, :public, :named_table])
_tid = :ets.new(@table_name, [:set, :public, :named_table])
Supervisor.init([], strategy: :one_for_one)
end

Expand Down
2 changes: 1 addition & 1 deletion lib/nostrum/cache/user_cache/ets.ex
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ defmodule Nostrum.Cache.UserCache.ETS do
@doc "Set up the ETS table."
@impl Supervisor
def init(_init_arg) do
:ets.new(@table_name, [:set, :public, :named_table])
_tid = :ets.new(@table_name, [:set, :public, :named_table])
Supervisor.init([], strategy: :one_for_one)
end

Expand Down
7 changes: 4 additions & 3 deletions lib/nostrum/consumer.ex
Original file line number Diff line number Diff line change
Expand Up @@ -435,9 +435,10 @@ defmodule Nostrum.Consumer do

@impl GenServer
def handle_info({:event, event}, state) do
Task.start_link(fn ->
__MODULE__.handle_event(event)
end)
{:ok, _pid} =
Task.start_link(fn ->
__MODULE__.handle_event(event)
end)

{:noreply, state}
end
Expand Down
6 changes: 3 additions & 3 deletions lib/nostrum/shard/dispatch.ex
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ defmodule Nostrum.Shard.Dispatch do

def handle_event(:GUILD_MEMBER_ADD = event, p, state) do
GuildCache.member_count_up(p.guild_id)
UserCache.create(p.user)
_new_user = UserCache.create(p.user)
{event, {p.guild_id, MemberCache.create(p.guild_id, p)}, state}
end

Expand Down Expand Up @@ -341,7 +341,7 @@ defmodule Nostrum.Shard.Dispatch do
voice = Voice.get_voice(p.guild_id)

if voice.persist_playback,
do: Voice.resume(p.guild_id)
do: _result = Voice.resume(p.guild_id)

{event, VoiceReady.to_struct(p), state}
end
Expand Down Expand Up @@ -382,7 +382,7 @@ defmodule Nostrum.Shard.Dispatch do
end
end

GuildCache.voice_state_update(p.guild_id, p)
{_updated, _states} = GuildCache.voice_state_update(p.guild_id, p)
{event, VoiceState.to_struct(p), state}
end

Expand Down
2 changes: 1 addition & 1 deletion lib/nostrum/store/guild_shard_mapping/ets.ex
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ defmodule Nostrum.Store.GuildShardMapping.ETS do
@doc "Set up the store's ETS table."
@impl Supervisor
def init(_init_arg) do
:ets.new(@table_name, [:set, :public, :named_table])
_tid = :ets.new(@table_name, [:set, :public, :named_table])
Supervisor.init([], strategy: :one_for_one)
end

Expand Down
2 changes: 1 addition & 1 deletion lib/nostrum/store/unavailable_guild/ets.ex
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ defmodule Nostrum.Store.UnavailableGuild.ETS do
@impl Supervisor
@doc "Set up the store's ETS table."
def init(_init_arg) do
:ets.new(@table_name, [:set, :public, :named_table])
_tid = :ets.new(@table_name, [:set, :public, :named_table])
Supervisor.init([], strategy: :one_for_one)
end

Expand Down
6 changes: 3 additions & 3 deletions lib/nostrum/voice.ex
Original file line number Diff line number Diff line change
Expand Up @@ -565,7 +565,7 @@ defmodule Nostrum.Voice do
voice = get_voice(guild_id)

if VoiceState.ready_for_rtp?(voice) do
Audio.send_frames(frames, voice)
{_, _sent_all?} = Audio.send_frames(frames, voice)
:ok
else
{:error, "Must be connected to voice channel to send frames."}
Expand All @@ -585,7 +585,7 @@ defmodule Nostrum.Voice do

cond do
VoiceState.ready_for_ws?(voice) ->
VoiceSupervisor.create_session(voice)
{:ok, _pid} = VoiceSupervisor.create_session(voice)
:ok

is_nil(voice) ->
Expand Down Expand Up @@ -765,7 +765,7 @@ defmodule Nostrum.Voice do
state = Map.put(state, guild_id, voice)

if Application.get_env(:nostrum, :voice_auto_connect, true),
do: start_if_ready(voice)
do: _result = start_if_ready(voice)

{:reply, voice, state}
end
Expand Down
15 changes: 8 additions & 7 deletions lib/nostrum/voice/audio.ex
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ defmodule Nostrum.Voice.Audio do
|> Enum.take(frames_per_burst())
|> send_frames(voice)

:timer.cancel(watchdog)
{:ok, :cancel} = :timer.cancel(watchdog)

if done,
do: on_complete(voice, init?),
Expand All @@ -129,12 +129,13 @@ defmodule Nostrum.Voice.Audio do
def send_frames(frames, %VoiceState{} = voice) do
voice =
Enum.reduce(frames, voice, fn f, v ->
:gen_udp.send(
v.udp_socket,
v.ip |> ip_to_tuple(),
v.port,
Crypto.encrypt(v, f)
)
:ok =
:gen_udp.send(
v.udp_socket,
v.ip |> ip_to_tuple(),
v.port,
Crypto.encrypt(v, f)
)

%{
v
Expand Down
4 changes: 3 additions & 1 deletion lib/nostrum/voice/ports.ex
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ defmodule Nostrum.Voice.Ports do
end
end

@dialyzer {:nowarn_function, init: 1}

alias Nostrum.Voice.Ports.State

require Logger
Expand All @@ -41,7 +43,7 @@ defmodule Nostrum.Voice.Ports do

# Spawn process to asynchronously send input to port
unless is_nil(input) do
Task.start(fn -> send_input(port, input) end)
{:ok, _pid} = Task.start(fn -> send_input(port, input) end)
end

# Store reference if input is another process
Expand Down
2 changes: 1 addition & 1 deletion lib/nostrum/voice/session.ex
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ defmodule Nostrum.Voice.Session do
) do
# Try to cancel the internal timer, but
# do not explode if it was already cancelled.
:timer.cancel(state.heartbeat_ref)
_cancel_result = :timer.cancel(state.heartbeat_ref)
{:noreply, state}
end

Expand Down
2 changes: 1 addition & 1 deletion lib/nostrum/voice/supervisor.ex
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,6 @@ defmodule Nostrum.Voice.Supervisor do
restart: :transient
}

DynamicSupervisor.start_child(Nostrum.Voice.SessionSupervisor, child)
{:ok, _pid} = DynamicSupervisor.start_child(Nostrum.Voice.SessionSupervisor, child)
end
end