Class: Danger::DangerUndercover

Inherits:
Plugin
  • Object
show all
Defined in:
lib/undercover/plugin.rb

Overview

Report missing coverage report using undercover and danger-undercover

You have to use [undercover](github.com/grodowski/undercover) to gather undercover report and send the report to this plugin so that danger-undercover can use it.

Examples:

Report missing coverage report


undercover.report('coverage/undercover.txt')

See Also:

  • nimblehq/danger-undercover

Constant Summary collapse

VALID_FILE_FORMAT =
'.txt'
DEFAULT_PATH =
'coverage/undercover.txt'

Instance Method Summary collapse

Instance Method Details

#report(undercover_path = DEFAULT_PATH, sticky: true) ⇒ void

This method returns an undefined value.

Checks the file validity and warns if no file is found if a valid file is found then if there are no changes, shows the report as a message in Danger. If there are reports then it shows the report as a warning in danger.



27
28
29
30
31
32
33
34
35
36
37
# File 'lib/undercover/plugin.rb', line 27

def report(undercover_path = DEFAULT_PATH, sticky: true)
  return fail('Undercover: coverage report cannot be found.') unless valid_file? undercover_path

  report = File.read(undercover_path, encoding: 'UTF-8')

  if report.match(/some methods have no test coverage/)
    warn(report, sticky: sticky)
  else
    message(report, sticky: sticky)
  end
end