Class: Steep::Drivers::DiagnosticPrinter::GitHubActionsFormatter

Inherits:
BaseFormatter show all
Defined in:
lib/steep/drivers/diagnostic_printer/github_actions_formatter.rb

Overview

Constant Summary collapse

ESCAPE_MAP =
{ '%' => '%25', "\n" => '%0A', "\r" => '%0D' }.freeze

Instance Attribute Summary

Attributes inherited from BaseFormatter

#buffer, #stdout

Instance Method Summary collapse

Methods inherited from BaseFormatter

#initialize, #path

Constructor Details

This class inherits a constructor from Steep::Drivers::DiagnosticPrinter::BaseFormatter

Instance Method Details



8
9
10
11
12
13
14
15
16
17
18
19
# File 'lib/steep/drivers/diagnostic_printer/github_actions_formatter.rb', line 8

def print(diagnostic, prefix: "", source: true)
  stdout.printf(
    "::%<severity>s file=%<file>s,line=%<line>d,endLine=%<endLine>d,col=%<column>d,endColumn=%<endColumn>d::%<message>s",
    severity: github_severity(diagnostic[:severity]),
    file: path,
    line: diagnostic[:range][:start][:line] + 1,
    endLine: diagnostic[:range][:end][:line] + 1,
    column: diagnostic[:range][:start][:character],
    endColumn: diagnostic[:range][:end][:character],
    message: github_escape("[#{diagnostic[:code]}] #{diagnostic[:message]}")
  )
end