Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/spoom/coverage.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
14 changes: 6 additions & 8 deletions lib/spoom/sorbet/config.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need this?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, otherwise the dup has shallow-copy semantics (arrays are shared). This makes it a deep copy (which is how #copy behaved).

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
Expand Down
9 changes: 5 additions & 4 deletions rbi/spoom.rbi
Original file line number Diff line number Diff line change
Expand Up @@ -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
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this considered a breaking change? Is this API public?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Go ahead and break it 👍


def ignore; end
def ignore=(_arg0); end

Expand All @@ -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
Expand Down
Loading