Skip to content

Commit

Permalink
Onboard Rubocop Naming/MemoizedInstanceVariableName rule to RubyGems.
Browse files Browse the repository at this point in the history
  • Loading branch information
simi authored and hsbt committed Mar 28, 2023
1 parent 2322b18 commit 1cbb501
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 7 deletions.
4 changes: 2 additions & 2 deletions lib/rubygems/command_manager.rb
Expand Up @@ -84,7 +84,7 @@ class Gem::CommandManager
# Return the authoritative instance of the command manager.

def self.instance
@command_manager ||= new
@instance ||= new
end

##
Expand All @@ -99,7 +99,7 @@ def instance
# Reset the authoritative instance of the command manager.

def self.reset
@command_manager = nil
@instance = nil
end

##
Expand Down
2 changes: 1 addition & 1 deletion lib/rubygems/installer.rb
Expand Up @@ -387,7 +387,7 @@ def run_post_install_hooks # :nodoc:
# we'll be installing into.

def installed_specs
@specs ||= begin
@installed_specs ||= begin
specs = []

Gem::Util.glob_files_in_dir("*.gemspec", File.join(gem_home, "specifications")).each do |path|
Expand Down
4 changes: 2 additions & 2 deletions lib/rubygems/request_set.rb
Expand Up @@ -108,7 +108,7 @@ def initialize(*deps)
@requests = []
@sets = []
@soft_missing = false
@sorted = nil
@sorted_requests = nil
@specs = nil
@vendor_set = nil
@source_set = nil
Expand Down Expand Up @@ -426,7 +426,7 @@ def resolve_current
end

def sorted_requests
@sorted ||= strongly_connected_components.flatten
@sorted_requests ||= strongly_connected_components.flatten
end

def specs
Expand Down
4 changes: 3 additions & 1 deletion lib/rubygems/specification.rb
Expand Up @@ -2236,7 +2236,7 @@ def original_platform # :nodoc:
# The platform this gem runs on. See Gem::Platform for details.

def platform
@new_platform ||= Gem::Platform::RUBY
@new_platform ||= Gem::Platform::RUBY # rubocop:disable Naming/MemoizedInstanceVariableName
end

def pretty_print(q) # :nodoc:
Expand Down Expand Up @@ -2711,6 +2711,8 @@ def reset_nil_attributes_to_default
end

@installed_by_version ||= nil

nil
end

def flatten_require_paths # :nodoc:
Expand Down
3 changes: 2 additions & 1 deletion lib/rubygems/stub_specification.rb
Expand Up @@ -182,14 +182,15 @@ def full_name
##
# The full Gem::Specification for this gem, loaded from evalling its gemspec

def to_spec
def spec
@spec ||= if @data
loaded = Gem.loaded_specs[name]
loaded if loaded && loaded.version == version
end

@spec ||= Gem::Specification.load(loaded_from)
end
alias_method :to_spec, :spec

##
# Is this StubSpecification valid? i.e. have we found a stub line, OR does
Expand Down

0 comments on commit 1cbb501

Please sign in to comment.