Class: KnifeSpork::Plugins::Rubocop
- Defined in:
- lib/knife-spork/plugins/rubocop.rb
Instance Method Summary collapse
Methods inherited from Plugin
#enabled?, hook, hooks, #initialize, name
Constructor Details
This class inherits a constructor from KnifeSpork::Plugins::Plugin
Instance Method Details
#epic_fail? ⇒ Boolean
47 48 49 |
# File 'lib/knife-spork/plugins/rubocop.rb', line 47 def epic_fail? config.epic_fail.nil? ? 'true' : config.epic_fail end |
#perform ⇒ Object
9 10 11 12 13 14 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 41 42 43 44 45 |
# File 'lib/knife-spork/plugins/rubocop.rb', line 9 def perform safe_require 'rubocop' safe_require 'rubocop/cli' safe_require 'rubocop/config_store' if Gem::Specification.find_all_by_name("rubocop").empty? ui.fatal "The knife-spork rubocop plugin requires rubocop." exit 1 end = [] = .concat([ "-D" ]) if config.show_name # Lists the name of the offense along with the description = .concat([ "--auto-correct" ]) if config.autocorrect = .concat([ "--out", config.out_file ]) if config.out_file # Specify a file output rather than STDOUT for the specific errors = .concat([ "--fail-level", config.sev_level ]) if config.sev_level # Specify a severity level for when rubocop should fail = .concat([ "--lint"]) if config.lint # Only run lint checks cookbooks.each do |cookbook| ui.info "Running rubocop against #{cookbook.name}@#{cookbook.version}..." cookbook_path = cookbook.root_dir ui.info cookbook_path = [ cookbook_path ] cli = defined?(RuboCop) ? ::RuboCop::CLI.new : ::Rubocop::CLI.new result = cli.run() unless result == 0 ui.error "Rubocop failed!" exit(1) if config.epic_fail else ui.info "Passed!" end end end |