Skip to content

Commit 532b681

Browse files
hanachinbbatsov
andauthored
Use ConfigLoader.default_configuration for default (#7632)
When the config file path is same as the default config file, use `ConfigLoader.default_configuration` instead of create a new config. Because some plugins add their default config values to `ConfigLoader.default_configuration`. So the Cops of the plugins expect that default config values exists. Fix rubocop/rubocop-rails#127 Co-authored-by: Bozhidar Batsov <bozhidar@batsov.com>
1 parent fc24294 commit 532b681

File tree

4 files changed

+7
-4
lines changed

4 files changed

+7
-4
lines changed

CHANGELOG.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
* [#7841](https://github.com/rubocop-hq/rubocop/issues/7841): Fix an error for `Style/TrailingCommaInBlockArgs` when lambda literal (`->`) has multiple arguments. ([@koic][])
2222
* [#7842](https://github.com/rubocop-hq/rubocop/issues/7842): Fix a false positive for `Lint/RaiseException` when Exception without cbase specified under the namespace `Gem` by adding `AllowedImplicitNamespaces` option. ([@koic][])
2323
* `Style/IfUnlessModifier` does not infinite-loop when autocorrecting long lines which use if/unless modifiers and have multiple statements separated by semicolons. ([@alexdowad][])
24+
* [rubocop-hq/rubocop-rails#127](https://github.com/rubocop-hq/rubocop-rails/issues/127): Use `ConfigLoader.default_configuration` for the default config. ([@hanachin][])
2425

2526
### Changes
2627

@@ -4441,6 +4442,7 @@
44414442
[@mangara]: https://github.com/mangara
44424443
[@pirj]: https://github.com/pirj
44434444
[@pawptart]: https://github.com/pawptart
4445+
[@hanachin]: https://github.com/hanachin
44444446
[@cetinajero]: https://github.com/cetinajero
44454447
[@gfyoung]: https://github.com/gfyoung
44464448
[@Tietew]: https://github.com/Tietew
@@ -4455,4 +4457,4 @@
44554457
[@rafaelfranca]: https://github.com/rafaelfranca
44564458
[@knu]: https://github.com/knu
44574459
[@saurabhmaurya15]: https://github.com/saurabhmaurya15
4458-
[@DracoAter]: https://github.com/DracoAter
4460+
[@DracoAter]: https://github.com/DracoAter

lib/rubocop/config_loader.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -84,9 +84,9 @@ def configuration_file_for(target_dir)
8484
end
8585

8686
def configuration_from_file(config_file)
87-
config = load_file(config_file)
88-
return config if config_file == DEFAULT_FILE
87+
return ConfigLoader.default_configuration if config_file == DEFAULT_FILE
8988

89+
config = load_file(config_file)
9090
if ignore_parent_exclusion?
9191
print 'Ignoring AllCops/Exclude from parent folders' if debug?
9292
else

spec/rubocop/cli/cli_options_spec.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -671,7 +671,7 @@ class SomeCop < Cop
671671
home = File.dirname(File.dirname(File.dirname(File.dirname(__FILE__))))
672672
expect($stdout.string.lines.grep(/configuration/).map(&:chomp))
673673
.to eq(["For #{abs('')}:" \
674-
" configuration from #{home}/config/default.yml"])
674+
" Default configuration from #{home}/config/default.yml"])
675675
end
676676

677677
it 'shows cop names' do

spec/support/cli_spec_behavior.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ def abs(path)
1111

1212
before do
1313
RuboCop::ConfigLoader.debug = false
14+
RuboCop::ConfigLoader.default_configuration = nil
1415

1516
# OPTIMIZE: Makes these specs faster. Work directory (the parent of
1617
# .rubocop_cache) is removed afterwards anyway.

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy