Reputation: 5735
My excludes are being ignored.
Rails:
Enabled: true
Exclude:
- 'db/**/*'
- 'config/**/*'
- 'script/**/*'
- 'bin/{rails,rake}'
- 'vendor/**/*'
- 'spec/fixtures/**/*'
- 'tmp/**/*'
Rubocop Message:
config/environments/development.rb:3:1: C: Metrics/BlockLength: Block has too many lines. [32/25] Rails.application.configure do ... ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ config/environments/production.rb:3:1: C: Metrics/BlockLength: Block has too many lines. [29/25] Rails.application.configure do ...
#!/usr/bin/env ruby
require 'english'
require 'rubocop'
ADDED_OR_MODIFIED = /A|AM|^M/.freeze
changed_files = `git status --porcelain`.split(/\n/).
select { |file_name_with_status|
file_name_with_status =~ ADDED_OR_MODIFIED
}.
map { |file_name_with_status|
file_name_with_status.split(' ')[1]
}.
select { |file_name|
File.extname(file_name) == '.rb'
}.join(' ')
system("rubocop --force-exclusion -a #{changed_files}") unless changed_files.empty?
status=$CHILD_STATUS.to_s[-1].to_i
if status == 0
system("echo -en '\\033[32mFormatting Passed, Committing...\\033[0;39m\n'")
exit 0
else
system("echo -en '\\033[1;31mCannot commit, formating failing. Use --no-verify to force commit.\\033[0;39m\n'")
exit 1
end
Upvotes: 2
Views: 1693
Reputation: 8777
Your configuration file only defines excludes for the Rails
department of cops, so it is correct that BlockLength
, which is in the Metrics
department, still inspects the files.
If what you meant to do was to ignore these files for all cops, you can use:
AllCops:
Exclude:
- 'db/**/*'
- 'config/**/*'
- 'script/**/*'
- 'bin/{rails,rake}'
- 'vendor/**/*'
- 'spec/fixtures/**/*'
- 'tmp/**/*'
Rails:
Enabled: true
Or if you just want to exclude the files for the Metrics
cops, substitute AllCops
for Metrics
in the configuration above.
Upvotes: 3