Class: Danger::DangerShellcheck

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

Overview

Shows the warnings and suggestions for shell scripts generated from ShellCheck. You need [ShellCheck](github.com/koalaman/shellcheck) installed and generating a json file to use this plugin.

Examples:

Showing summary


shellcheck -f json myscript > shellcheck.json
shellcheck.report 'shellcheck.json'

See Also:

  • IntrepidPursuits/danger-shellcheck

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#project_rootString

The project root, which will be used to make the paths relative. Defaults to ‘pwd’.

Returns:

  • (String)

    project_root value



20
21
22
# File 'lib/shellcheck/plugin.rb', line 20

def project_root
  @project_root
end

#sticky_summaryBoolean

Defines if the test summary will be sticky or not Defaults to ‘false’

Returns:

  • (Boolean)

    sticky



25
26
27
# File 'lib/shellcheck/plugin.rb', line 25

def sticky_summary
  @sticky_summary
end

Instance Method Details

#report(file_path) ⇒ void

This method returns an undefined value.

Reads a file with JSON ShellCheck summary and reports it.

Parameters:

  • file_path (String)

    Path for ShellCheck summary in JSON format.



41
42
43
44
45
# File 'lib/shellcheck/plugin.rb', line 41

def report(file_path)
  raise 'ShellCheck summary file not found' unless File.file?(file_path)
  shellcheck_summary = JSON.parse(File.read(file_path), symbolize_names: true)
  run_summary(shellcheck_summary)
end