Onboard Rubocop Naming/MemoizedInstanceVariableName rule to RubyGems.

This commit is contained in:
Josef Šimánek 2023-03-24 20:41:46 +01:00 committed by Hiroshi SHIBATA
parent 2322b189b6
commit 1cbb501127
No known key found for this signature in database
GPG Key ID: F9CF13417264FAC2
5 changed files with 10 additions and 7 deletions

View File

@ -84,7 +84,7 @@ class Gem::CommandManager
# Return the authoritative instance of the command manager. # Return the authoritative instance of the command manager.
def self.instance def self.instance
@command_manager ||= new @instance ||= new
end end
## ##
@ -99,7 +99,7 @@ class Gem::CommandManager
# Reset the authoritative instance of the command manager. # Reset the authoritative instance of the command manager.
def self.reset def self.reset
@command_manager = nil @instance = nil
end end
## ##

View File

@ -387,7 +387,7 @@ class Gem::Installer
# we'll be installing into. # we'll be installing into.
def installed_specs def installed_specs
@specs ||= begin @installed_specs ||= begin
specs = [] specs = []
Gem::Util.glob_files_in_dir("*.gemspec", File.join(gem_home, "specifications")).each do |path| Gem::Util.glob_files_in_dir("*.gemspec", File.join(gem_home, "specifications")).each do |path|

View File

@ -108,7 +108,7 @@ class Gem::RequestSet
@requests = [] @requests = []
@sets = [] @sets = []
@soft_missing = false @soft_missing = false
@sorted = nil @sorted_requests = nil
@specs = nil @specs = nil
@vendor_set = nil @vendor_set = nil
@source_set = nil @source_set = nil
@ -426,7 +426,7 @@ class Gem::RequestSet
end end
def sorted_requests def sorted_requests
@sorted ||= strongly_connected_components.flatten @sorted_requests ||= strongly_connected_components.flatten
end end
def specs def specs

View File

@ -2236,7 +2236,7 @@ class Gem::Specification < Gem::BasicSpecification
# The platform this gem runs on. See Gem::Platform for details. # The platform this gem runs on. See Gem::Platform for details.
def platform def platform
@new_platform ||= Gem::Platform::RUBY @new_platform ||= Gem::Platform::RUBY # rubocop:disable Naming/MemoizedInstanceVariableName
end end
def pretty_print(q) # :nodoc: def pretty_print(q) # :nodoc:
@ -2711,6 +2711,8 @@ class Gem::Specification < Gem::BasicSpecification
end end
@installed_by_version ||= nil @installed_by_version ||= nil
nil
end end
def flatten_require_paths # :nodoc: def flatten_require_paths # :nodoc:

View File

@ -182,7 +182,7 @@ class Gem::StubSpecification < Gem::BasicSpecification
## ##
# The full Gem::Specification for this gem, loaded from evalling its gemspec # The full Gem::Specification for this gem, loaded from evalling its gemspec
def to_spec def spec
@spec ||= if @data @spec ||= if @data
loaded = Gem.loaded_specs[name] loaded = Gem.loaded_specs[name]
loaded if loaded && loaded.version == version loaded if loaded && loaded.version == version
@ -190,6 +190,7 @@ class Gem::StubSpecification < Gem::BasicSpecification
@spec ||= Gem::Specification.load(loaded_from) @spec ||= Gem::Specification.load(loaded_from)
end end
alias_method :to_spec, :spec
## ##
# Is this StubSpecification valid? i.e. have we found a stub line, OR does # Is this StubSpecification valid? i.e. have we found a stub line, OR does