Skip to content

Commit b6a6672

Browse files
committed
fix: replace more wrong comparisons
1 parent 6d83e58 commit b6a6672

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

lib/opencov/services/github/checks.ex

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ defmodule Librecov.Services.Github.Checks do
66
alias Librecov.Project
77
alias Librecov.Services.Github.AuthData
88
import Librecov.Helpers.Coverage
9+
import Librecov.Helpers.Number
910

1011
def finish_check(
1112
%AuthData{token: token, owner: owner, repo: repo},
@@ -81,7 +82,7 @@ defmodule Librecov.Services.Github.Checks do
8182
)
8283
end
8384

84-
defp diff_conclusion(diff) when diff == 0, do: "neutral"
85+
defp diff_conclusion(diff) when is_zero(diff), do: "neutral"
8586
defp diff_conclusion(diff) when diff < 0, do: "failure"
8687
defp diff_conclusion(diff) when diff > 0, do: "success"
8788
end

lib/web/views/common_view.ex

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11
defmodule Librecov.CommonView do
2+
import Librecov.Helpers.Number
23
def format_coverage(num) when is_float(num), do: "#{Float.round(num, 1)}%"
34
def format_coverage(_), do: "NA"
45

56
def coverage_color(coverage) do
67
cond do
78
is_nil(coverage) -> "na"
8-
coverage == 0 -> "none"
9+
is_zero(coverage) -> "none"
910
coverage < 80 -> "low"
1011
coverage < 90 -> "normal"
1112
coverage < 100 -> "good"

0 commit comments

Comments
 (0)