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

fix: Dialyzer useless control flow #73

Merged
merged 2 commits into from
Jun 11, 2020
Merged
Changes from 1 commit
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
18 changes: 8 additions & 10 deletions lib/nebulex/caching/decorators.ex
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,7 @@ defmodule Nebulex.Caching.Decorators do
defp caching_action(action, attrs, block, context) do
cache = attrs[:cache] || raise ArgumentError, "expected cache: to be given as argument"

key_var = Keyword.get(attrs, :key)
key_var = Keyword.get(attrs, :key, quote do: :erlang.phash2({unquote(context.module), unquote(context.name)}))
keys_var = Keyword.get(attrs, :keys, [])
match_var = Keyword.get(attrs, :match)

Expand All @@ -241,7 +241,7 @@ defmodule Nebulex.Caching.Decorators do

quote do
cache = unquote(cache)
key = unquote(key_var) || :erlang.phash2({unquote(context.module), unquote(context.name)})
key = unquote(key_var)
keys = unquote(keys_var)
opts = unquote(opts_var)
match = unquote(match_var) || fn _ -> true end
Expand All @@ -257,11 +257,10 @@ defmodule Nebulex.Caching.Decorators do
else
value = unquote(block)

if apply(match, [value]) do
cache.set(key, value, opts)
else
value
cond do
cabol marked this conversation as resolved.
Show resolved Hide resolved
apply(match, [value]) -> cache.set(key, value, opts)
end
value
end
end
end
Expand All @@ -287,11 +286,10 @@ defmodule Nebulex.Caching.Decorators do
quote do
value = unquote(block)

if apply(match, [value]) do
cache.set(key, value, opts)
else
value
cond do
cabol marked this conversation as resolved.
Show resolved Hide resolved
apply(match, [value]) -> cache.set(key, value, opts)
end
value
end
end
end