ExSlop.Check.Readability.StepComment (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

"Step 1: ..." comments indicate the function is doing too much. Extract each step into its own well-named function.

# bad
def process(data) do
  # Step 1: Validate the input
  validated = validate(data)
  # Step 2: Transform the data
  transformed = transform(validated)
  # Step 3: Save to database
  save(transformed)
end

# good — the pipe IS the steps
def process(data) do
  data
  |> validate()
  |> transform()
  |> save()
end

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.