Skip to content

Commit 31ec3a5

Browse files
authored
Merge pull request #889 from Shopify/Alex/replace-manual-copy-with-dup
Replace manual `#copy` with standard `#dup`
2 parents 1cad67e + a7bb154 commit 31ec3a5

3 files changed

Lines changed: 12 additions & 13 deletions

File tree

lib/spoom/coverage.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ def snapshot(context, rbi: true, sorbet_bin: nil)
1515
config = context.sorbet_config
1616
config.allowed_extensions.push(".rb", ".rbi") if config.allowed_extensions.empty?
1717

18-
new_config = config.copy
18+
new_config = config.dup
1919
new_config.allowed_extensions.reject! { |ext| !rbi && ext == ".rbi" }
2020
flags = [
2121
"--no-config",

lib/spoom/sorbet/config.rb

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -40,14 +40,12 @@ def initialize
4040
@no_stdlib = false #: bool
4141
end
4242

43-
#: -> Config
44-
def copy
45-
new_config = Sorbet::Config.new
46-
new_config.paths.concat(@paths)
47-
new_config.ignore.concat(@ignore)
48-
new_config.allowed_extensions.concat(@allowed_extensions)
49-
new_config.no_stdlib = @no_stdlib
50-
new_config
43+
#: (Config source) -> void
44+
def initialize_copy(source)
45+
super
46+
@paths = @paths.dup
47+
@ignore = @ignore.dup
48+
@allowed_extensions = @allowed_extensions.dup
5149
end
5250

5351
# Returns self as a string of options that can be passed to Sorbet

rbi/spoom.rbi

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2603,10 +2603,6 @@ class Spoom::Sorbet::Config
26032603

26042604
def allowed_extensions; end
26052605
def allowed_extensions=(_arg0); end
2606-
2607-
sig { returns(::Spoom::Sorbet::Config) }
2608-
def copy; end
2609-
26102606
def ignore; end
26112607
def ignore=(_arg0); end
26122608

@@ -2623,6 +2619,11 @@ class Spoom::Sorbet::Config
26232619

26242620
def paths=(_arg0); end
26252621

2622+
private
2623+
2624+
sig { params(source: ::Spoom::Sorbet::Config).void }
2625+
def initialize_copy(source); end
2626+
26262627
class << self
26272628
sig { params(sorbet_config_path: ::String).returns(::Spoom::Sorbet::Config) }
26282629
def parse_file(sorbet_config_path); end

0 commit comments

Comments
 (0)