Switch branches/tags
Nothing to show
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
55 lines (44 sloc) 1.66 KB
require 'rubocop/rake_task'
# rubocop: disable Metrics/BlockLength
# Add additional test suite definitions to the default test task here
namespace :test do
desc 'Runs RuboCop on specified directories' do |task|
# Dirs: app, lib, test
task.patterns = ['app/**/*.rb', 'lib/**/*.rb', 'test/**/*.rb']
# Make it easier to disable cops.
task.options << "--display-cop-names"
# Abort on failures (fix your code first)
task.fail_on_error = false
desc 'Runs Brakeman'
# based on
task :brakeman, :output_files do |_task, args|
# Abort on failures (fix your code first)
EXIT_ON_FAIL = false
require 'brakeman'
files = args[:output_files].split(' ') if args[:output_files]
# For more options, see source here:
options = {
app_path: ".",
exit_on_error: EXIT_ON_FAIL,
exit_on_warn: EXIT_ON_FAIL,
output_files: files,
print_report: true,
pager: false,
summary_only: true
tracker = options
failures = tracker.filtered_warnings + tracker.errors
# Based on code here:
if EXIT_ON_FAIL && failures.any?
puts 'Brakeman violations found. Aborting now...'
exit Brakeman::Warnings_Found_Exit_Code unless tracker.filtered_warnings.empty?
exit Brakeman::Errors_Found_Exit_Code if tracker.errors.any?
# rubocop: enable Metrics/BlockLength
Rake::Task[:test].enhance ['test:rubocop', 'test:brakeman']