-
Notifications
You must be signed in to change notification settings - Fork 48
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
Suggestion of smell: complex else clauses in with #7
Comments
there's a way to know error from which clause: 😂 with {:read_file, {:ok, encoded}} <- {:read_file, File.read(...)},
{:decode, {:ok, value}} <- {:decode, Base.decode64(encoded)} do
value
else
{:read_file , {:error, _}} -> :badfile
{:decode, :error} -> :badencoding
end and highly recommend section "Avoid |
@fishtreesugar yeah, That’s discouraged too. I think we even updated the docs to mention it. :) |
Just linking to the docs :) beware |
I added this smell to the catalog as well. Looks good? https://github.com/lucasvegi/Elixir-Code-Smells#complex-else-clauses-in-with |
Excellent!! |
It is a small to match on different else results in with:
That's because it is impossible to know from which clause the error value came from. Instead, you should normalize the return types in the clauses:
The text was updated successfully, but these errors were encountered: