Created
August 14, 2016 17:52
-
-
Save hayduke19us/33ae0a2e705486eb27e65473678b0c0e to your computer and use it in GitHub Desktop.
This file contains hidden or 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
begin | |
require 'rubocop/rake_task' | |
modified_files = `git diff --name-only`.split(" ").map(&:strip) | |
included_files = modified_files.select { |f| f =~ /.*.rb\z/ } | |
if included_files.any? | |
RuboCop::RakeTask.new do |t| | |
t.patterns = included_files | |
end | |
else | |
desc 'Rubocop has no modified files to check' | |
task :rubocop do | |
puts 'No modified files for robocop to check' | |
end | |
end | |
rescue LoadError | |
desc 'Rubocop rake task not available (rubocop not installed)' | |
task :rubocop do | |
abort 'Rubocop rake task is not available.' | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment