Skip to content

Commit

Permalink
Merge branch 'master' into master
Browse files Browse the repository at this point in the history
  • Loading branch information
RKushnir committed Apr 24, 2024
2 parents c8f16ef + d09ee95 commit 6d1c3d5
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
10 changes: 9 additions & 1 deletion lib/excoveralls/cobertura.ex
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ defmodule ExCoveralls.Cobertura do
c_paths
|> Enum.find_value(package_name, fn c_path ->
if String.starts_with?(package_name, c_path) do
String.slice(package_name, (String.length(c_path) + 1)..-1)
String.slice(package_name, get_slice_range_for_package_name(c_path))
else
false
end
Expand All @@ -183,6 +183,14 @@ defmodule ExCoveralls.Cobertura do
|> to_charlist()
end

# TODO: Remove when we require Elixir 1.12 as minimum and inline it with range syntax
if Version.match?(System.version(), ">= 1.12.0") do
# We use Range.new/3 because using x..y//step would give a syntax error on Elixir < 1.12
defp get_slice_range_for_package_name(c_path), do: Range.new(String.length(c_path) + 1, -1, 1)
else
defp get_slice_range_for_package_name(c_path), do: (String.length(c_path) + 1)..-1
end

defp rate(valid_lines) when length(valid_lines) == 0, do: 0.0

defp rate(valid_lines) do
Expand Down
2 changes: 1 addition & 1 deletion mix.exs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ defmodule ExCoveralls.Mixfile do
def project do
[
app: :excoveralls,
version: "0.18.0",
version: "0.18.1",
elixir: "~> 1.11",
elixirc_paths: elixirc_paths(Mix.env()),
deps: deps(),
Expand Down

0 comments on commit 6d1c3d5

Please sign in to comment.