Class: Browsable::Formatters::Github

Inherits:
Object
  • Object
show all
Defined in:
lib/browsable/formatters/github.rb

Overview

Emits GitHub Actions workflow commands so findings surface as inline annotations on a pull request. See: docs.github.com/actions/reference/workflow-commands-for-github-actions

Constant Summary collapse

LEVELS =
{ error: "error", warning: "warning", info: "notice" }.freeze

Instance Method Summary collapse

Constructor Details

#initialize(report) ⇒ Github

Returns a new instance of Github.



11
12
13
# File 'lib/browsable/formatters/github.rb', line 11

def initialize(report)
  @report = report
end

Instance Method Details

#renderObject



15
16
17
18
19
20
21
22
23
24
# File 'lib/browsable/formatters/github.rb', line 15

def render
  lines = @report.findings.map { |finding| annotation(finding) }

  if (suggestion = @report.suggestion)
    lines << "::notice title=#{escape_property('browsable: suggested allow_browser')}::" \
             "#{escape_data(suggestion.line)}"
  end

  lines.join("\n")
end