Cane, Flay, Brakeman rake tasks with non-zero exit code
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
namespace :brakeman do | |
desc "Run Brakeman" | |
task :run, :output_files do |t, args| | |
begin | |
require 'brakeman' | |
files = args[:output_files].split(' ') if args[:output_files] | |
tracker = Brakeman.run app_path: ".", output_files: files, print_report: false, ignore_model_output: true | |
puts "Running Brakeman..." | |
if tracker.checks.all_warnings.length != 0 | |
puts tracker.report | |
puts "Found #{tracker.checks.all_warnings.length} view warnings, should be 0." | |
puts "Found #{tracker.checks.warnings.length} security warnings, should be 0." | |
puts "Found #{tracker.errors.length} parse errors (these can be ignored)." | |
fail "!!! Brakeman found warnings that need to be fixed !!!" | |
end | |
puts "Brakeman Finished! No warnings found." | |
rescue LoadError | |
warn "Brakeman not available." | |
end | |
end | |
end | |
namespace :cane do | |
desc "Run Cane" | |
task :run do | |
begin | |
require 'cane/cli' | |
puts "Running Cane..." | |
# will pick up .cane from root of project | |
unless Cane::CLI.run([]) | |
fail "!!! Cane found warnings that need to be fixed !!!" | |
end | |
puts "Cane Finished! No warnings found." | |
rescue LoadError | |
warn "Cane not available." | |
end | |
end | |
end | |
namespace :flay do | |
desc "Run Flay" | |
task :run do | |
begin | |
require "flay" | |
puts "Running Flay..." | |
flay = Flay.new({mass: 30}) | |
flay.process(*Flay.expand_dirs_to_files(%w[app])) | |
fail "!!! Flay found warnings that need to be fixed !!!" if flay.report.size >= 1 | |
puts "Flay Finished! No warnings found." | |
rescue LoadError | |
warn "Flay not available." | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment