Class: Pronto::ShellCheckRunner
- Inherits:
-
Runner
- Object
- Runner
- Pronto::ShellCheckRunner
- Extended by:
- Forwardable
- Defined in:
- lib/pronto/shellcheck_runner.rb
Constant Summary collapse
- EXTENSION =
/^\..*sh$/
- SHEBANG =
%r{^#!/.*sh}
- SHELLCHECK_PRONTO_LEVELS =
{ 'style' => :info, 'info' => :info, 'error' => :error, 'warning' => :warning }.freeze
Class Method Summary collapse
- .file_has_shebang?(path) ⇒ Boolean
- .path_has_extension?(path) ⇒ Boolean
- .regular_file?(path) ⇒ Boolean
- .shellcheckable?(path) ⇒ Boolean
Instance Method Summary collapse
Class Method Details
.file_has_shebang?(path) ⇒ Boolean
41 42 43 44 |
# File 'lib/pronto/shellcheck_runner.rb', line 41 def file_has_shebang?(path) shebang = File.readlines(path).first !(SHEBANG =~ shebang).nil? end |
.path_has_extension?(path) ⇒ Boolean
37 38 39 |
# File 'lib/pronto/shellcheck_runner.rb', line 37 def path_has_extension?(path) !(EXTENSION =~ path.extname).nil? end |
.regular_file?(path) ⇒ Boolean
33 34 35 |
# File 'lib/pronto/shellcheck_runner.rb', line 33 def regular_file?(path) File.file?(path) end |
.shellcheckable?(path) ⇒ Boolean
28 29 30 31 |
# File 'lib/pronto/shellcheck_runner.rb', line 28 def shellcheckable?(path) regular_file?(path) && (path_has_extension?(path) || file_has_shebang?(path)) end |
Instance Method Details
#run ⇒ Object
19 20 21 22 23 24 25 |
# File 'lib/pronto/shellcheck_runner.rb', line 19 def run return [] if !@patches || @patches.count.zero? @patches .select { |patch| patch.additions > 0 && shellcheckable?(patch.new_file_full_path) } .reduce([]) { |results, patch| results.concat(inspect(patch)) } end |