From ab7ef1631e74197bb5932d7a0de447981664b39c Mon Sep 17 00:00:00 2001 From: Koichi ITO Date: Tue, 4 Feb 2025 20:54:04 +0900 Subject: [PATCH] Suppress redundant configuration logging for rubocop-performace `rubocop-performance-1.23.1/config/default.yml` is being output twice: ```console $ bundle exec rubocop -d path/to/example.rb (snip) For /Users/koic/src/github.com/rubocop/rubocop-rails: configuration from /Users/koic/src/github.com/rubocop/rubocop-rails/.rubocop.yml configuration from /Users/koic/src/github.com/rubocop/rubocop-rails/config/default.yml configuration from /Users/koic/.rbenv/versions/3.4.1/lib/ruby/gems/3.4.0/bundler/gems/rubocop-da31e5acaa98/config/internal_affairs.yml configuration from /Users/koic/.rbenv/versions/3.4.1/lib/ruby/gems/3.4.0/bundler/gems/rubocop-da31e5acaa98/config/internal_affairs.yml Default configuration from /Users/koic/.rbenv/versions/3.4.1/lib/ruby/gems/3.4.0/bundler/gems/rubocop-da31e5acaa98/config/default.yml configuration from /Users/koic/.rbenv/versions/3.4.1/lib/ruby/gems/3.4.0/gems/rubocop-performance-1.23.1/config/default.yml configuration from /Users/koic/.rbenv/versions/3.4.1/lib/ruby/gems/3.4.0/gems/rubocop-performance-1.23.1/config/default.yml ``` Since it is already logged by `ConfigLoader.load_yaml_configuration`: https://github.com/rubocop/rubocop/blob/v1.71.2/lib/rubocop/config_loader.rb#L71-L82 The unnecessary code on the caller side will be removed. --- lib/rubocop/performance/inject.rb | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/lib/rubocop/performance/inject.rb b/lib/rubocop/performance/inject.rb index b89fd14c3..bb9a712c8 100644 --- a/lib/rubocop/performance/inject.rb +++ b/lib/rubocop/performance/inject.rb @@ -9,9 +9,8 @@ def self.defaults! path = CONFIG_DEFAULT.to_s hash = ConfigLoader.load_yaml_configuration(path) config = Config.new(hash, path).tap(&:make_excludes_absolute) - puts "configuration from #{path}" if ConfigLoader.debug? - config = ConfigLoader.merge_with_default(config, path) - ConfigLoader.instance_variable_set(:@default_configuration, config) + new_config = ConfigLoader.merge_with_default(config, path) + ConfigLoader.instance_variable_set(:@default_configuration, new_config) end end end