redline
LowAI tellsobvious-docstring

Docstring restates the name

Docstring restates the name. The docstring restates the name get_user. Say what a reader can't see: units, edge cases, why.

This is how the comment reads inline, under the flagged line.

Why it matters

'Get the user.' on get_user tells nothing new. Docstrings earn their place with units, edge cases and failure modes.

What to do

Delete it, or say what the name can't.

Examples

Flagged
def get_user(user_id):
    """Get the user."""
Better
def get_user(user_id):
    """Return the user, or raise NotFound. Reads the replica."""

What it catches

It reads the shape of the code: functions, blocks, loops and calls. Languages: Python. Scope: All files. These cases are the rule's own tests: the first set must be flagged and the second must not.

Flagged

def get_user(user_id):
    """Gets the user."""
    return 1

Left alone

def get_user(user_id):
    """Read from the replica; may lag by a second."""
    return 1

Research

Comments and docstrings that repeat the next line, the function name or the structure ("Step 1", "This function handles"). The reader learns nothing, and the comment drifts out of date when the code changes.

Turn it off or change it

In a config file for the CLI, or in the API's rules field:

{
  "rules": {
    "disable": [
      "obvious-docstring"
    ],
    "severity": {
      "obvious-docstring": "medium"
    }
  }
}

Read the source or report a false positive.