Bylaw.Credo.Check.Elixir.NoPassthroughWrapper
(bylaw_credo v0.1.0-alpha.1)
Copy Markdown
View Source
Basics
This check is disabled by default.
Learn how to enable it via .credo.exs.
This check has a base priority of high and works with any version of Elixir.
Explanation
Avoid private functions that only forward their arguments to a single call. Inline the call instead.
Examples
Avoid:
defp format_datetime(datetime), do: DateTime.to_iso8601(datetime)Prefer:
DateTime.to_iso8601(datetime)If the wrapper name materially improves readability, keep it and disable this check locally:
# credo:disable-for-next-line Bylaw.Credo.Check.Elixir.NoPassthroughWrapper
defp format_datetime(datetime), do: DateTime.to_iso8601(datetime)Notes
This check uses static AST analysis, so it favors clear source-level patterns over runtime behavior.
Options
Configure options in .credo.exs with the check tuple:
%{
configs: [
%{
name: "default",
checks: [
{Bylaw.Credo.Check.Elixir.NoPassthroughWrapper,
[
include_public: true
]}
]
}
]
}:include_public- When true, also report publicdefpassthrough wrappers
Usage
Add this check to Credo's checks: list in .credo.exs:
%{
configs: [
%{
name: "default",
checks: [
{Bylaw.Credo.Check.Elixir.NoPassthroughWrapper, []}
]
}
]
}Check-Specific Parameters
Use the following parameters to configure this check:
:include_public
When true, also report public def passthrough wrappers
This parameter defaults to false.
General Parameters
Like with all checks, general params can be applied.
Parameters can be configured via the .credo.exs config file.