Class: Claws::Rule::Shellcheck
- Defined in:
- lib/claws/rule/shellcheck.rb
Instance Attribute Summary
Attributes inherited from BaseRule
#configuration, #on_job, #on_step, #on_workflow
Instance Method Summary collapse
-
#shellcheck(workflow:, job:, step:) ⇒ Object
rubocop:disable Lint/UnusedMethodArgument, Metrics/AbcSize.
Methods inherited from BaseRule
#data, description, extract_value, #initialize, #inspect, #name, name, on_job, on_step, on_workflow, parse_rule, #to_s
Constructor Details
This class inherits a constructor from BaseRule
Instance Method Details
#shellcheck(workflow:, job:, step:) ⇒ Object
rubocop:disable Lint/UnusedMethodArgument, Metrics/AbcSize
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/claws/rule/shellcheck.rb', line 15 def shellcheck(workflow:, job:, step:) # rubocop:disable Lint/UnusedMethodArgument, Metrics/AbcSize unless File.exist? shellcheck_bin warn "Couldn't find shellcheck binary (#{shellcheck_bin}).\n" warn "Make sure it's installed and configure `shellcheck_bin` appropriately." exit 1 end return if step["run"].nil? shell = if step["shell"].nil? identify_shell(step["run"]) else step["shell"] end return if shell.nil? exit_status, stdout, = analyze_script(step["run"], shell) return unless exit_status == 1 Violation.new( line: step.keys.filter { |x| x == "run" }.first.line, description: "Shellcheck found some issues with this shell script:\n#{stdout}" ) end |