     for part <- Regex.split(regex, str, on: [:head, :tail], trim: true) do
       case part do
         "$" <> code -> compile_code(String.to_atom(code))
-        _           -> part
+        _ -> part
       end
     end
   end
 
   defp compile_code(key) when key in @valid_patterns, do: key
+
   defp compile_code(key) when is_atom(key) do
-    raise(ArgumentError, message: "$#{key} is an invalid format pattern.")
+    raise ArgumentError, "$#{key} is an invalid format pattern."
   end
 
   @doc """


  Typically called after formatting when the data cannot be printed.
  """
  @spec prune(IO.chardata) :: IO.chardata
  def prune(binary) when is_binary(binary), do: prune_binary(binary, "")
  def prune([h | t]) when h in 0..1114111, do: [h | prune(t)]
  def prune([h | t]), do: [prune(h) | prune(t)]
  def prune([]), do: []
  def prune(_), do: @replacement

  defp prune_binary(<<h::utf8, t::binary>>, acc),
    do: prune_binary(t, <<acc::binary, h::utf8>>)
  defp prune_binary(<<_, t::binary>>, acc),
    do: prune_binary(t, <<acc::binary, @replacement>>)
  defp prune_binary(<<>>, acc),
    do: acc

  @doc ~S"""
  Compiles a format string into a data structure that the `format/5` can handle.

  defp metadata(pid) when is_pid(pid) do
    :erlang.pid_to_list(pid)
  end

  defp metadata(ref) when is_reference(ref) do
    '#Ref' ++ rest = :erlang.ref_to_list(ref)
    rest
  end

  defp metadata(atom) when is_atom(atom) do
    case Atom.to_string(atom) do
      "Elixir." <> rest -> rest
