Skip to content

Commit

Permalink
Add option for filtering out full covered files from HTML report
Browse files Browse the repository at this point in the history
  • Loading branch information
albertored committed May 12, 2022
1 parent a716e6e commit 6482d8e
Show file tree
Hide file tree
Showing 4 changed files with 65 additions and 54 deletions.
7 changes: 5 additions & 2 deletions README.md
Expand Up @@ -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)
Expand Down Expand Up @@ -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:
Expand All @@ -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
}
}
```
Expand Down
6 changes: 5 additions & 1 deletion lib/excoveralls/html.ex
Expand Up @@ -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
Expand Down
104 changes: 54 additions & 50 deletions lib/templates/html/htmlcov/coverage.html.eex

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion test/html_test.exs
Expand Up @@ -5,7 +5,7 @@ defmodule ExCoveralls.HtmlTest do
alias ExCoveralls.Html

@file_name "excoveralls.html"
@file_size 20191
@file_size 20375
@test_output_dir "cover_test/"
@test_template_path "lib/templates/html/htmlcov/"

Expand Down

0 comments on commit 6482d8e

Please sign in to comment.