From a7bb154c56d54bcb31e581281110b8ade27657fb Mon Sep 17 00:00:00 2001 From: Alexander Momchilov Date: Wed, 1 Apr 2026 15:46:56 -0400 Subject: [PATCH] Replace manual `#copy` with standard `#dup` --- lib/spoom/coverage.rb | 2 +- lib/spoom/sorbet/config.rb | 14 ++++++-------- rbi/spoom.rbi | 9 +++++---- 3 files changed, 12 insertions(+), 13 deletions(-) diff --git a/lib/spoom/coverage.rb b/lib/spoom/coverage.rb index 92b99a24..6079f976 100644 --- a/lib/spoom/coverage.rb +++ b/lib/spoom/coverage.rb @@ -15,7 +15,7 @@ def snapshot(context, rbi: true, sorbet_bin: nil) config = context.sorbet_config config.allowed_extensions.push(".rb", ".rbi") if config.allowed_extensions.empty? - new_config = config.copy + new_config = config.dup new_config.allowed_extensions.reject! { |ext| !rbi && ext == ".rbi" } flags = [ "--no-config", diff --git a/lib/spoom/sorbet/config.rb b/lib/spoom/sorbet/config.rb index 5bc76195..14b15ce5 100644 --- a/lib/spoom/sorbet/config.rb +++ b/lib/spoom/sorbet/config.rb @@ -40,14 +40,12 @@ def initialize @no_stdlib = false #: bool end - #: -> Config - def copy - new_config = Sorbet::Config.new - new_config.paths.concat(@paths) - new_config.ignore.concat(@ignore) - new_config.allowed_extensions.concat(@allowed_extensions) - new_config.no_stdlib = @no_stdlib - new_config + #: (Config source) -> void + def initialize_copy(source) + super + @paths = @paths.dup + @ignore = @ignore.dup + @allowed_extensions = @allowed_extensions.dup end # Returns self as a string of options that can be passed to Sorbet diff --git a/rbi/spoom.rbi b/rbi/spoom.rbi index f9abe5a6..10d9b27c 100644 --- a/rbi/spoom.rbi +++ b/rbi/spoom.rbi @@ -2603,10 +2603,6 @@ class Spoom::Sorbet::Config def allowed_extensions; end def allowed_extensions=(_arg0); end - - sig { returns(::Spoom::Sorbet::Config) } - def copy; end - def ignore; end def ignore=(_arg0); end @@ -2623,6 +2619,11 @@ class Spoom::Sorbet::Config def paths=(_arg0); end + private + + sig { params(source: ::Spoom::Sorbet::Config).void } + def initialize_copy(source); end + class << self sig { params(sorbet_config_path: ::String).returns(::Spoom::Sorbet::Config) } def parse_file(sorbet_config_path); end