Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

.eex template error: no function clause matching in Enum.reverse_slice/3 #67

Closed
kipcole9 opened this issue Aug 28, 2016 · 3 comments
Closed

Comments

@kipcole9
Copy link

coveralls 0.5.5 on Erlang/OTP 19 for mix coveralls.html results in:

** (FunctionClauseError) no function clause matching in Enum.reverse_slice/3
    (elixir) lib/enum.ex:1864: Enum.reverse_slice(["cldr.ex", "lib"], 1, #Function<3.4269533/1 in ExCoveralls.Html.View.render/1>)
    lib/templates/html/htmlcov/coverage.html.eex:17: anonymous fn/2 in ExCoveralls.Html.View.render/1

The offending line is in coverage.html.eex:

<% [b | s] = String.split(file.filename, "/") |> Enum.reverse |> Enum.reverse_slice(1, &(&1.length)) %>'

Here the code is calling Enum.reverse_slice(["path", "components"], 1, &(&1.length)) which doesn't make sense to me since the third argument should be a count which should be an integer. I assume the intent is to dynamically determine the length of the list in the first argument, but this code doesn't do that.

Possible fix

Change line 17 to:

<% parts = String.split(file.filename, "/") %>
<% [b | s] = parts |> Enum.reverse |> Enum.reverse_slice(1, Enum.count(parts))%>

This appears to work (in my system).

parroty added a commit that referenced this issue Aug 28, 2016
parroty added a commit that referenced this issue Aug 28, 2016
@parroty
Copy link
Owner

parroty commented Aug 28, 2016

Thanks for the report. Does the above fix matches your expectation? I tried to simulate the same error, but I haven't been able to yet (though your comment makes sense).
(line is tweaked for avoiding the test error with minimum change).

@kipcole9
Copy link
Author

Confirmed the patch fixes the issue i was seeing.

parroty added a commit that referenced this issue Aug 29, 2016
Fix for  .eex template error (#67)
@parroty
Copy link
Owner

parroty commented Aug 29, 2016

Thanks, pushed as v0.5.6.

@parroty parroty closed this as completed Aug 29, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants