Credence.Pattern.NoTrailingNewlineInDoc
(credence v0.4.2)
Copy Markdown
Detects @doc, @moduledoc, and @typedoc strings that contain a
trailing \n escape sequence.
LLMs frequently generate documentation strings with a trailing \n
because Python docstrings use trailing newlines. In Elixir, the closing
" or """ handles line termination — the \n produces an
unnecessary blank line in the rendered documentation.
Bad
@doc "Finds the missing number in a list.\n"
@moduledoc "A module for palindrome checking.\n"Good
@doc "Finds the missing number in a list."
@moduledoc "A module for palindrome checking."Auto-fix
Strips trailing \n from single-line doc strings (strings where the
only newlines are trailing). Heredoc-style docs (""") are not flagged
or modified — their trailing \n is structural and expected.