Rbtz.CredoChecks.Readability.PreferToTimeout (rbtz_credo_checks v0.4.0)

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 normal and works with any version of Elixir.

Explanation

Prefers the Elixir 1.17+ Kernel.to_timeout/1 helper over Erlang's :timer.seconds/1, :timer.minutes/1, :timer.hours/1, and :timer.hms/3.

to_timeout/1 is self-documenting, composes multiple units in a single call, and keeps timeout construction in idiomatic Elixir rather than Erlang interop.

Bad

:timer.seconds(30)
:timer.minutes(15)
:timer.hours(1)
:timer.hms(1, 30, 0)

Good

to_timeout(second: 30)
to_timeout(minute: 15)
to_timeout(hour: 1)
to_timeout(hour: 1, minute: 30)

Check-Specific Parameters

There are no specific parameters for this check.

General Parameters

Like with all checks, general params can be applied.

Parameters can be configured via the .credo.exs config file.