Credence.Syntax.CloseUnclosedDocHeredoc (credence v0.8.0)

Copy Markdown

Detects and fixes unclosed @doc heredocs where the LLM jumps straight into function code without ever closing the triple-quote block.

LLMs frequently emit @doc followed by triple-quotes on their own line and then immediately write a def on the next non-blank line without a closing set of triple-quotes in between. This causes a TokenMissingError (missing terminator). The fix inserts a closing triple-quote line — indented to match the @doc line — immediately before the def line.

Bad (won't parse — TokenMissingError)

defmodule Solution do
  @doc """
  def find_min_max(list) do
    Enum.min_max(list)
  end
end

Good

defmodule Solution do
  @doc """
  """
  def find_min_max(list) do
    Enum.min_max(list)
  end
end