ExSlop.Check.Readability.ObviousComment (ExSlop v0.4.2)

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

Comments that restate what the next line of code does are noise. This check only flags very short comments (under 60 chars) that start with a verb + article and contain no technical detail.

# bad
# Fetch the user
user = Repo.get(User, id)

# Create the changeset
changeset = User.changeset(user, attrs)

# Return the result
{:ok, changeset}

# good — no comment needed, the code is clear

# good — explains HOW or WHY (not flagged despite starting with "Fetch")
# Fetch the connection from the pool, blocking up to 5s
conn = ConnectionPool.checkout!(pool, timeout: 5_000)

Check-Specific Parameters

Use the following parameters to configure this check:

:additional_keywords

Additional string prefixes or regexes to match against the comment text after #.

This parameter defaults to [].

General Parameters

Like with all checks, general params can be applied.

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