From 1cbb5011274399527c26eb3c6dd98c7947140f83 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Josef=20=C5=A0im=C3=A1nek?= Date: Fri, 24 Mar 2023 20:41:46 +0100 Subject: Onboard Rubocop Naming/MemoizedInstanceVariableName rule to RubyGems. --- lib/rubygems/command_manager.rb | 4 ++-- lib/rubygems/installer.rb | 2 +- lib/rubygems/request_set.rb | 4 ++-- lib/rubygems/specification.rb | 4 +++- lib/rubygems/stub_specification.rb | 3 ++- 5 files changed, 10 insertions(+), 7 deletions(-) diff --git a/lib/rubygems/command_manager.rb b/lib/rubygems/command_manager.rb index 1a0ad2ad8a..c53f0231af 100644 --- a/lib/rubygems/command_manager.rb +++ b/lib/rubygems/command_manager.rb @@ -84,7 +84,7 @@ class Gem::CommandManager # Return the authoritative instance of the command manager. def self.instance - @command_manager ||= new + @instance ||= new end ## @@ -99,7 +99,7 @@ class Gem::CommandManager # Reset the authoritative instance of the command manager. def self.reset - @command_manager = nil + @instance = nil end ## diff --git a/lib/rubygems/installer.rb b/lib/rubygems/installer.rb index f252abf296..fdb2944272 100644 --- a/lib/rubygems/installer.rb +++ b/lib/rubygems/installer.rb @@ -387,7 +387,7 @@ class Gem::Installer # 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| diff --git a/lib/rubygems/request_set.rb b/lib/rubygems/request_set.rb index e1447ad49b..46e9cc346c 100644 --- a/lib/rubygems/request_set.rb +++ b/lib/rubygems/request_set.rb @@ -108,7 +108,7 @@ class Gem::RequestSet @requests = [] @sets = [] @soft_missing = false - @sorted = nil + @sorted_requests = nil @specs = nil @vendor_set = nil @source_set = nil @@ -426,7 +426,7 @@ class Gem::RequestSet end def sorted_requests - @sorted ||= strongly_connected_components.flatten + @sorted_requests ||= strongly_connected_components.flatten end def specs diff --git a/lib/rubygems/specification.rb b/lib/rubygems/specification.rb index 8ad95cc3fe..8498dc6363 100644 --- a/lib/rubygems/specification.rb +++ b/lib/rubygems/specification.rb @@ -2236,7 +2236,7 @@ class Gem::Specification < Gem::BasicSpecification # 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: @@ -2711,6 +2711,8 @@ class Gem::Specification < Gem::BasicSpecification end @installed_by_version ||= nil + + nil end def flatten_require_paths # :nodoc: diff --git a/lib/rubygems/stub_specification.rb b/lib/rubygems/stub_specification.rb index 975e250c36..a3793eaa20 100644 --- a/lib/rubygems/stub_specification.rb +++ b/lib/rubygems/stub_specification.rb @@ -182,7 +182,7 @@ class Gem::StubSpecification < Gem::BasicSpecification ## # 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 @@ -190,6 +190,7 @@ class Gem::StubSpecification < Gem::BasicSpecification @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 -- cgit v1.2.3