diff --git a/README.md b/README.md index da53e68..6a5bae3 100644 --- a/README.md +++ b/README.md @@ -87,7 +87,7 @@ end - [[mix coveralls.html] Show coverage as HTML report](#mix-coverallshtml-show-coverage-as-html-report) - [[mix coveralls.json] Show coverage as JSON report](#mix-coverallsjson-show-coverage-as-json-report) - [[mix coveralls.xml] Show coverage as XML report](#mix-coverallsxml-show-coverage-as-xml-report) - - [[mix coveralls.lcov] Show coverage as lcov repor (Experimental)](#mix-coverallslcov-show-coverage-as-lcov-report-experimental) + - [[mix coveralls.lcov] Show coverage as lcov report (Experimental)](#mix-coverallslcov-show-coverage-as-lcov-report-experimental) - [coveralls.json](#coverallsjson) - [Stop Words](#stop-words) - [Exclude Files](#exclude-files) @@ -424,6 +424,8 @@ to `false`: - A custom path for html reports. This defaults to the htmlcov report in the excoveralls lib. - `minimum_coverage` - When set to a number greater than 0, this setting causes the `mix coveralls` and `mix coveralls.html` tasks to exit with a status code of 1 if test coverage falls below the specified threshold (defaults to 0). This is useful to interrupt CI pipelines with strict code coverage rules. Should be expressed as a number between 0 and 100 signifying the minimum percentage of lines covered. +- `html_filter_full_covered` + - A boolean, when `true` files with 100% coverage are not shown in the HTML report. Default to `false`. Example configuration file: @@ -444,7 +446,8 @@ Example configuration file: "output_dir": "cover/", "template_path": "custom/path/to/template/", "minimum_coverage": 90, - "xml_base_dir": "custom/path/for/xml/reports/" + "xml_base_dir": "custom/path/for/xml/reports/", + "html_filter_full_covered": true } } ``` diff --git a/lib/excoveralls/html.ex b/lib/excoveralls/html.ex index 29737af..be8d742 100644 --- a/lib/excoveralls/html.ex +++ b/lib/excoveralls/html.ex @@ -21,7 +21,11 @@ defmodule ExCoveralls.Html do defp generate_report(map, output_dir) do IO.puts("Generating report...") - View.render(cov: map) |> write_file(output_dir) + + filter_full_covered = + Map.get(ExCoveralls.Settings.get_coverage_options(), "html_filter_full_covered", false) + + View.render(cov: map, filter_full_covered: filter_full_covered) |> write_file(output_dir) end defp output_dir(output_dir) do diff --git a/lib/templates/html/htmlcov/coverage.html.eex b/lib/templates/html/htmlcov/coverage.html.eex index 65e1aea..b501429 100644 --- a/lib/templates/html/htmlcov/coverage.html.eex +++ b/lib/templates/html/htmlcov/coverage.html.eex @@ -12,16 +12,18 @@ @@ -33,47 +35,49 @@
<%= for file <- @cov.files do %> -
-

<%= file.filename %>

-
-
<%= file.coverage || 0 %>
-
<%= file.sloc %>
-
<%= file.hits %>
-
<%= file.misses %>
-
- - - - - - - - - <%= for {line, number} <- Enum.with_index(file.source) do %> - <%= cond do %> - <% line.coverage > 0 && line.coverage != nil -> %> - - - - - - <% 0 == line.coverage -> %> - - - - - - <% true -> %> - - - - - + <%= if not @filter_full_covered or file.coverage < 100 do %> +
+

<%= file.filename %>

+
+
<%= file.coverage || 0 %>
+
<%= file.sloc %>
+
<%= file.hits %>
+
<%= file.misses %>
+
+
LineHitsSource
<%= number %><%= line.coverage %><%= ExCoveralls.Html.View.safe line.source %>
<%= number %>0<%= ExCoveralls.Html.View.safe line.source %>
<%= number %><%= ExCoveralls.Html.View.safe(line.source || ' ') %>
+ + + + + + + + <%= for {line, number} <- Enum.with_index(file.source) do %> + <%= cond do %> + <% line.coverage > 0 && line.coverage != nil -> %> + + + + + + <% 0 == line.coverage -> %> + + + + + + <% true -> %> + + + + + + <% end %> <% end %> - <% end %> - -
LineHitsSource
<%= number %><%= line.coverage %><%= ExCoveralls.Html.View.safe line.source %>
<%= number %>0<%= ExCoveralls.Html.View.safe line.source %>
<%= number %><%= ExCoveralls.Html.View.safe(line.source || ' ') %>
-
+ + +
+ <% end %> <% end %>