Class: Gergich::Capture::ShellcheckCapture

Inherits:
BaseCapture
  • Object
show all
Defined in:
lib/gergich/capture/shellcheck_capture.rb

Constant Summary collapse

SEVERITY_MAP =
{
  "style" => "info",
  "info" => "info",
  "warning" => "warn",
  "error" => "error"
}.freeze

Instance Method Summary collapse

Methods inherited from BaseCapture

inherited, normalize_captor_class_name

Instance Method Details

#run(output) ⇒ Object



16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/gergich/capture/shellcheck_capture.rb', line 16

def run(output)
  JSON.parse(output).map do |warning|
    severity = warning.fetch("level")
    {
      path: warning.fetch("file"),
      position: warning.fetch("line"),
      message: warning.fetch("message"),
      severity: SEVERITY_MAP.fetch(severity),
      source: "shellcheck"
    }
  end
end