lib/plugins/pre_commit/checks/rubocop.rb in pre-commit-0.22.1 vs lib/plugins/pre_commit/checks/rubocop.rb in pre-commit-0.23.0
- old
+ new
@@ -16,10 +16,27 @@
def call(staged_files)
require 'rubocop'
rescue LoadError => e
$stderr.puts "Could not find rubocop: #{e}"
else
- staged_files = staged_files.grep(/\.rb$/)
+ allowed_files_regex = /\.gemspec\Z|
+ \.podspec\Z|
+ \.jbuilder\Z|
+ \.rake\Z|
+ \.opal\Z|
+ \.rb\Z|
+ Gemfile\Z|
+ Rakefile\Z|
+ Capfile\Z|
+ Guardfile\Z|
+ Podfile\Z|
+ Thorfile\Z|
+ Vagrantfile\Z|
+ Berksfile\Z|
+ Cheffile\Z|
+ Vagabondfile\Z
+ /x
+ staged_files = staged_files.grep(allowed_files_regex)
return if staged_files.empty?
args = config_file_flag + user_supplied_flags + ["--force-exclusion"] + staged_files
success, captured = capture { ::RuboCop::CLI.new.run(args) == 0 }