lib/rubocop/cli/command/auto_generate_config.rb in rubocop-1.66.1 vs lib/rubocop/cli/command/auto_generate_config.rb in rubocop-1.67.0

- old
+ new

@@ -149,19 +149,18 @@ .sub(/#{PLACEHOLDER}\n*/o, "inherit_from:#{file_string}\n\n") .sub(/\n\n+\Z/, "\n")) end def relative_path_to_todo_from_options_config - return AUTO_GENERATED_FILE if !@options[:config] || options_config_in_root? + return AUTO_GENERATED_FILE unless @options[:config] - base = Pathname.new('.') - config_dir = Pathname.new(File.dirname(@options[:config])) + base = Pathname.new(Dir.pwd) + config_dir = Pathname.new(@options[:config]).realpath.dirname - "#{base.relative_path_from(config_dir)}/#{AUTO_GENERATED_FILE}" - end + # Don't have the path start with `/` + return AUTO_GENERATED_FILE if config_dir == base - def options_config_in_root? - File.dirname(@options[:config]) == '.' + "#{base.relative_path_from(config_dir)}/#{AUTO_GENERATED_FILE}" end end end end end