Skip to content

Commit

Permalink
Always floor coverage instead of rounding
Browse files Browse the repository at this point in the history
We do not want to report a 100% coverage when there are lines
that are not covered.
  • Loading branch information
albertored committed May 24, 2023
1 parent 07a89a3 commit 88789a3
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
10 changes: 5 additions & 5 deletions lib/excoveralls/local.ex
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ defmodule ExCoveralls.Local do
@moduledoc """
Locally displays the result to screen.
"""



defmodule Count do
@moduledoc """
Expand Down Expand Up @@ -145,16 +145,16 @@ defmodule ExCoveralls.Local do
end

defp format_info([stat, count]) do
coverage = get_coverage(count)
coverage = count |>get_coverage() |> Float.floor(1)
file_width = ExCoveralls.Settings.get_file_col_width
print_string("~5.1f% ~-#{file_width}s ~8w ~8w ~8w",
print_string("~5w% ~-#{file_width}s ~8w ~8w ~8w",
[coverage, stat[:name], count.lines, count.relevant, count.relevant - count.covered])
end

defp format_total(info) do
totals = Enum.reduce(info, %Count{}, fn([_, count], acc) -> append(count, acc) end)
coverage = get_coverage(totals)
print_string("[TOTAL] ~5.1f%", [coverage])
"[TOTAL] #{Float.floor(coverage, 1)}%"
end

defp append(a, b) do
Expand Down
2 changes: 1 addition & 1 deletion lib/excoveralls/stats.ex
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@ defmodule ExCoveralls.Stats do
if value == trunc(value) do
trunc(value)
else
Float.round(value, 1)
Float.floor(value, 1)
end
end

Expand Down

0 comments on commit 88789a3

Please sign in to comment.