From 99850b1bd8723503b83ac1d06996f3bedf70ef00 Mon Sep 17 00:00:00 2001 From: Randy Stauner Date: Thu, 22 Oct 2026 13:14:07 -0700 Subject: [PATCH] Stop rubocop benchmark from applying configs in parent dirs The benchmarks error when this repo is checked out underneath another dir that has a .rubocop.yml that requires rubocop-minitest. --- benchmarks/rubocop/benchmark.rb | 33 +++++++++++++++++++-------------- 1 file changed, 19 insertions(+), 14 deletions(-) diff --git a/benchmarks/rubocop/benchmark.rb b/benchmarks/rubocop/benchmark.rb index 12f415a0..df907f66 100644 --- a/benchmarks/rubocop/benchmark.rb +++ b/benchmarks/rubocop/benchmark.rb @@ -14,20 +14,25 @@ # integrates with RuboCop class RuboCopRunner < RuboCop::Runner def initialize - super( - ::RuboCop::Options.new.parse( - [ - "--stderr", - "--force-exclusion", - "--format", - "RuboCop::Formatter::BaseFormatter", - "--raise-cop-error", - "--autocorrect", - ] - ).first, - ::RuboCop::ConfigStore.new - ) - + args = [ + "--stderr", + "--force-exclusion", + "--format", + "RuboCop::Formatter::BaseFormatter", + "--raise-cop-error", + "--autocorrect", + # Without this, RuboCop searches upwards for a .rubocop.yml (and falls back to + # ~/.rubocop.yml), so the amount of work done would depend on where this repo + # happens to be checked out. Always benchmark against RuboCop's default config. + "--force-default-config", + ] + options, _paths = ::RuboCop::Options.new.parse(args) + + config_store = ::RuboCop::ConfigStore.new + # This is how `RuboCop::CLI` applies the option to the config store + config_store.force_default_config! if options[:force_default_config] + + super(options, config_store) end def run(path, contents)