Skip to content

Commit

Permalink
Fix an issue that excluded files in rubocop-rails did not work
Browse files Browse the repository at this point in the history
`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
  • Loading branch information
sinsoku committed Jan 20, 2020
1 parent 85cc839 commit 61b7567
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

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

## 2.4.1 (2019-12-25)

Expand Down
2 changes: 1 addition & 1 deletion lib/rubocop/rails/inject.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ module Inject
def self.defaults!
path = CONFIG_DEFAULT.to_s
hash = ConfigLoader.send(:load_yaml_configuration, path)
config = Config.new(hash, path)
config = Config.new(hash, path).tap(&:make_excludes_absolute)
puts "configuration from #{path}" if ConfigLoader.debug?
config = ConfigLoader.merge_with_default(config, path, unset_nil: false)
ConfigLoader.instance_variable_set(:@default_configuration, config)
Expand Down
16 changes: 16 additions & 0 deletions spec/rubocop/rails/inject_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# frozen_string_literal: true

RSpec.describe RuboCop::Rails::Inject do
describe '#defaults!' do
before { allow(Dir).to receive(:pwd).and_return('/home/foo/project') }

it 'makes excludes absolute' do
configuration = described_class.defaults!
expect(configuration['AllCops']['Exclude'])
.to include(
'/home/foo/project/bin/*',
'/home/foo/project/db/schema.rb'
)
end
end
end

0 comments on commit 61b7567

Please sign in to comment.