elixir-analyzer icon indicating copy to clipboard operation
elixir-analyzer copied to clipboard

rpg-character sheet analysis should allow for helper function.

Open iteratee opened this issue 2 years ago • 1 comments

  defp print_charmap(charmap) do
    IO.inspect(charmap, label: "Your character")
  end

  def run() do
    with :ok <- welcome(),
         name <- ask_name(),
         class <- ask_class(),
         level <- ask_level() do
      print_charmap(%{name: name, class: class, level: level})
    end
  end

The analyzer complains with the following:

Essential IO.inspect has a handy option :label that helps adding context to a printed value. Use it in run/0.

Essential The function run/0 should not explicitly return the result, but return whatever IO.inspect returns (which is its first argument).

Both of which shouldn't trigger. I am returning the result of IO.inspect in tail position, and I'm using label: in the helper.

iteratee avatar Oct 05 '22 16:10 iteratee

Right, we didn't anticipate the use of helper functions. We also didn't anticipate the use of with since it's not been introduced yet. Do you get comments when you replace print_charmap by IO.inspect?

jiegillet avatar Oct 06 '22 00:10 jiegillet

I'm going to close this as I didn't receive an answer to my question. Also, the use of with is a bit out of place here since no pattern match can fail, and the use of a helper function for replacing one line is a bit unusual. I'll be happy to revisit the topic if we receive more complaints.

jiegillet avatar Dec 04 '22 12:12 jiegillet