Rbtz.CredoChecks.Readability.AtomHttpStatusCodes
(rbtz_credo_checks v0.2.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
Forbids passing integer HTTP status codes to Plug.Conn and Phoenix
controller helpers; use the corresponding atoms instead.
Atoms (:ok, :not_found, :unprocessable_entity, ...) read more
naturally than three-digit numbers, surface typos at compile time, and
work uniformly across all Plug.Conn helpers.
The check fires when a literal integer in the 100-599 range is passed
as the status argument to send_resp/3, put_status/2, or resp/3
(whether called directly or via |>, locally or as Plug.Conn /
Phoenix.Controller remote calls).
Bad
put_status(conn, 404)
send_resp(conn, 200, body)
Plug.Conn.resp(conn, 500, "oops")Good
put_status(conn, :not_found)
send_resp(conn, :ok, body)
Plug.Conn.resp(conn, :internal_server_error, "oops")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.