ExSlop.Check.Readability.NarratorDoc (ExSlop v0.3.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 low and works with any version of Elixir.

Explanation

@moduledoc and @doc that begin with "This module/function provides..." are narrator comments — they restate what the module or function name already says.

# bad
@moduledoc """
This module provides functionality for handling user authentication.
"""
defmodule MyApp.Auth do

# bad
@doc """
This function creates a new user.
"""
def create_user(attrs)

# good — explain WHY, not WHAT
@moduledoc """
Wraps Bcrypt and session token generation.
Rate-limits login attempts per IP via a sliding window.
"""

# good — document behavior, constraints, examples
@doc """
Passwords must be at least 12 characters. Returns
`{:error, :weak_password}` for common dictionary words.

## Examples

    iex> create_user(%{email: "a@b.c", password: "hunter2"})
    {:error, :weak_password}
"""

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.