Class: Danger::DangerCobertura
- Inherits:
-
Plugin
- Object
- Plugin
- Danger::DangerCobertura
- Defined in:
- lib/cobertura/plugin.rb
Overview
Show code coverage of modified and added files. Add warnings if minimum file coverage is not achieved.
Constant Summary collapse
- ERROR_FILE_NOT_SET =
"Cobertura file not set. Use 'cobertura.file = \"path/to/my/report.xml\"'.".freeze
- ERROR_FILE_NOT_FOUND =
"No file found at %s".freeze
- TABLE_COLUMN_LINE =
"-----".freeze
Instance Attribute Summary collapse
-
#additional_headers ⇒ Array<Symbol>
Array of symbols which allows to extend the markdown report columns.
-
#filename_prefix ⇒ String
Path prefix to be added to the cobertura class filename attribute.
-
#report ⇒ String
Path to the xml formatted cobertura report.
Instance Method Summary collapse
-
#fail_if_file_less_than(percentage:) ⇒ Array<String>
Fail if a modified file has a lower total coverage than defined.
-
#show_coverage ⇒ Array<String>
Show markdown table of modified and added files.
-
#warn_if_file_less_than(percentage:) ⇒ Array<String>
Warn if a modified file has a lower total coverage than defined.
Instance Attribute Details
#additional_headers ⇒ Array<Symbol>
Array of symbols which allows to extend the markdown report columns. Allowed symbols: :branch, :line
29 30 31 |
# File 'lib/cobertura/plugin.rb', line 29 def additional_headers @additional_headers end |
#filename_prefix ⇒ String
Path prefix to be added to the cobertura class filename attribute.
33 34 35 |
# File 'lib/cobertura/plugin.rb', line 33 def filename_prefix @filename_prefix end |
#report ⇒ String
Path to the xml formatted cobertura report.
24 25 26 |
# File 'lib/cobertura/plugin.rb', line 24 def report @report end |
Instance Method Details
#fail_if_file_less_than(percentage:) ⇒ Array<String>
Fail if a modified file has a lower total coverage than defined.
51 52 53 54 55 56 57 |
# File 'lib/cobertura/plugin.rb', line 51 def fail_if_file_less_than(percentage:) filtered_items.each do |item| next unless item.total_percentage < percentage fail "#{item.name} has less than #{percentage}% coverage" end end |
#show_coverage ⇒ Array<String>
Show markdown table of modified and added files. TODO remove * wildcard to accept all parameter: ‘danger local` bug - github.com/danger/danger/issues/1041
62 63 64 65 66 67 68 69 70 71 72 73 |
# File 'lib/cobertura/plugin.rb', line 62 def show_coverage(*) return if filtered_items.empty? table = "## Code coverage\n".dup table << table_header table << table_separation filtered_items.each do |item| table << table_entry(item) end markdown table end |
#warn_if_file_less_than(percentage:) ⇒ Array<String>
Warn if a modified file has a lower total coverage than defined.
39 40 41 42 43 44 45 |
# File 'lib/cobertura/plugin.rb', line 39 def warn_if_file_less_than(percentage:) filtered_items.each do |item| next unless item.total_percentage < percentage warn "#{item.name} has less than #{percentage}% coverage" end end |