Class: Danger::Reporter

Inherits:
Plugin
  • Object
show all
Defined in:
lib/dangermattic/plugins/common/reporter.rb

Overview

Handles reporting messages in the context of Danger, allowing the generation of warnings, errors, and simple messages in a Danger run.

Examples:

Reporting a Warning

reporter.report(message: "This is a warning message", type: :warning)

Reporting an Error

reporter.report(message: "This is an error message", type: :error)

See Also:

  • Automattic/dangermattic

Instance Method Summary collapse

Instance Method Details

#report(message:, type: :warning) ⇒ void

This method returns an undefined value.

Report a message to be posted by Danger as an error (failing the build), a warning or a simple message.

Parameters:

  • message (String)

    The message to be reported to Danger.

  • type (Symbol) (defaults to: :warning)

    The type of report. Possible values:

    • :warning (default): Reports a warning.
    • :error: Reports an error.
    • :message: Reports a simple message.
    • Any other value or nil: Takes no action.


27
28
29
30
31
32
33
34
35
36
# File 'lib/dangermattic/plugins/common/reporter.rb', line 27

def report(message:, type: :warning)
  case type
  when :error
    failure(message)
  when :warning
    warn(message)
  when :message
    danger.message(message)
  end
end