 
   defp issue_for(issue_meta, line_no) do
     format_issue issue_meta,
-      message: "Logger usage is not lazzy",
+      message: "Prefer lazy Logger calls.",
       line_no: line_no
   end
 
-  defp logger_import?([{:__aliases__, _meta, [:Logger]}]) do
-    true
-  end
-  defp logger_import?(_ast) do
-    false
-  end
-
+  defp logger_import?([{:__aliases__, _meta, [:Logger]}]), do: true
+  defp logger_import?(_), do: false
 end

  defp traverse({:import, _meta, arguments} = ast, state, _issue_meta) do
    if logger_import?(arguments) do
      {_, issue_list} = state
      {ast, {true, issue_list}}
    else
      {ast, state}

  @moduledoc """
  Ensures laziness of Logger calls.

  The best practice is to wrap an expensive logger calls into a zero argument
  function (`fn -> "input" end`).

  Example:

      # NOT preferred
      # the interpolation is executed whether or not the info is logged
      Logger.debug "This happened: \#{expensive_calculation(arg1, arg2)}"

      # preferred
      Logger.debug fn ->
        "This happened: \#{expensive_calculation(arg1, arg2)}"
      end
  """
  @explanation [check: @moduledoc]
  @levels [:debug, :info, :warn, :error]
  @default_params [
    levels: @levels,
  ]

  use Credo.Check, base_priority: :high

  @doc false
  def run(%SourceFile{} = source_file, params \\ []) do
    issue_meta = IssueMeta.for(source_file, params)
    state = {false, []} # {<Logger import seen?>, <list of issues>}
    {_, issues} =
      Credo.Code.prewalk(source_file, &traverse(&1, &2, issue_meta), state)

    issues
  end

