exercism / elixir-analyzer

GNU Affero General Public License v3.0
30 stars 32 forks source link

rpg-character sheet analysis should allow for helper function. #338

Closed iteratee closed 1 year ago

iteratee commented 1 year ago
  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.

jiegillet commented 1 year ago

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 commented 1 year ago

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.