KogenCredo.Check.Warning.DiscardedResult (KogenCredo v0.1.0)
View SourceBasics
This check is disabled by default.
Learn how to enable it via .credo.exs.
This check has a base priority of low and works with any version of Elixir.
Explanation
A fallible call whose result is dropped hides failures.
Bad:
_ = Repo.update(changeset)
Enum.each(attrs, fn a -> create_post(a) end)Good:
{:ok, _post} = Repo.update(changeset)
Enum.each(attrs, fn a -> {:ok, _} = create_post(a) end)Or collect results and handle the errors. Fallibility is guessed from
function names; tune fallible_name_patterns and ignored_names.
Check-Specific Parameters
Use the following parameters to configure this check:
:repo_functions
Repo functions that are fallible (non-bang writes).
This parameter defaults to [:insert, :update, :delete, :insert_or_update].
:fallible_name_patterns
Globs of function names treated as fallible.
This parameter defaults to ["create_*", "insert_*", "update_*", "delete_*"].
:ignored_names
Function names never treated as fallible.
This parameter defaults to ["update_in", "update_change", "delete_change", "update_counter", "delete_csrf_token", "delete_session", "delete_req_header", "delete_resp_header", "delete_resp_cookie", "update_resp_header"].
:ignored_modules
Last module segments whose functions are never fallible.
This parameter defaults to ["Map", "Keyword", "Enum", "List", "Access", "Changeset", "Multi", "Kernel"].
:flag_bare_statement
Report fallible calls used as statements (default true).
This parameter defaults to true.
:flag_underscore_assignment
Report _ = fallible() statements (default true).
This parameter defaults to true.
:repo_names
Last module segments accepted as a repo (default ["Repo"]).
This parameter defaults to ["Repo"].
:repo_modules
Full repo module names accepted as a repo (strings).
This parameter defaults to [].
:included_paths
Globs of files to check; empty means every file.
This parameter defaults to [].
:excluded_paths
Globs of files to skip (default ["test/**"]).
This parameter defaults to ["test/**"].
General Parameters
Like with all checks, general params can be applied.
Parameters can be configured via the .credo.exs config file.