Skip to content

Commit 61b7567

Browse files
committed
Fix an issue that excluded files in rubocop-rails did not work
`bin/*` and `db/schema.rb` were not excluded. Exclude files should be absolute paths internally, so it fixes to call the `make_excludes_absolute` method. Ref: rubocop/rubocop@cb63798
1 parent 85cc839 commit 61b7567

File tree

3 files changed

+18
-1
lines changed

3 files changed

+18
-1
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66

77
* [#184](https://github.com/rubocop-hq/rubocop-rails/issues/184): Fix `Rake/Environment` to allow task with no block. ([@hanachin][])
88
* [#122](https://github.com/rubocop-hq/rubocop-rails/issues/122): Fix `Exclude` paths that were not inherited. ([@koic][])
9+
* [#187](https://github.com/rubocop-hq/rubocop-rails/pull/187): Fix an issue that excluded files in rubocop-rails did not work. ([@sinsoku][])
910

1011
## 2.4.1 (2019-12-25)
1112

lib/rubocop/rails/inject.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ module Inject
88
def self.defaults!
99
path = CONFIG_DEFAULT.to_s
1010
hash = ConfigLoader.send(:load_yaml_configuration, path)
11-
config = Config.new(hash, path)
11+
config = Config.new(hash, path).tap(&:make_excludes_absolute)
1212
puts "configuration from #{path}" if ConfigLoader.debug?
1313
config = ConfigLoader.merge_with_default(config, path, unset_nil: false)
1414
ConfigLoader.instance_variable_set(:@default_configuration, config)

spec/rubocop/rails/inject_spec.rb

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# frozen_string_literal: true
2+
3+
RSpec.describe RuboCop::Rails::Inject do
4+
describe '#defaults!' do
5+
before { allow(Dir).to receive(:pwd).and_return('/home/foo/project') }
6+
7+
it 'makes excludes absolute' do
8+
configuration = described_class.defaults!
9+
expect(configuration['AllCops']['Exclude'])
10+
.to include(
11+
'/home/foo/project/bin/*',
12+
'/home/foo/project/db/schema.rb'
13+
)
14+
end
15+
end
16+
end

0 commit comments

Comments
 (0)