From 1ca67f13cd2ebb643fc924246cc790f14b26480d Mon Sep 17 00:00:00 2001 From: Hiroshi SHIBATA Date: Thu, 16 Mar 2023 13:12:38 +0900 Subject: util/rubocop -A --only Style/RedundantSelf --- lib/rubygems.rb | 2 +- lib/rubygems/basic_specification.rb | 12 ++++++------ lib/rubygems/command.rb | 2 +- lib/rubygems/commands/push_command.rb | 2 +- lib/rubygems/commands/yank_command.rb | 2 +- lib/rubygems/dependency.rb | 16 ++++++++-------- lib/rubygems/deprecate.rb | 6 +++--- lib/rubygems/gemcutter_utilities.rb | 6 +++--- lib/rubygems/remote_fetcher.rb | 6 +++--- lib/rubygems/specification.rb | 32 ++++++++++++++++---------------- 10 files changed, 43 insertions(+), 43 deletions(-) (limited to 'lib') diff --git a/lib/rubygems.rb b/lib/rubygems.rb index 5a73cfc9ad..00749bc0cf 100644 --- a/lib/rubygems.rb +++ b/lib/rubygems.rb @@ -1136,7 +1136,7 @@ An Array (#{env.inspect}) was passed in from #{caller[3]} # This is used throughout RubyGems for enabling reproducible builds. def self.source_date_epoch - Time.at(self.source_date_epoch_string.to_i).utc.freeze + Time.at(source_date_epoch_string.to_i).utc.freeze end # FIX: Almost everywhere else we use the `def self.` way of defining class diff --git a/lib/rubygems/basic_specification.rb b/lib/rubygems/basic_specification.rb index 82db52dc3b..51c043d5fc 100644 --- a/lib/rubygems/basic_specification.rb +++ b/lib/rubygems/basic_specification.rb @@ -269,7 +269,7 @@ class Gem::BasicSpecification # Return all files in this gem that match for +glob+. def matches_for_glob(glob) # TODO: rename? - glob = File.join(self.lib_dirs_glob, glob) + glob = File.join(lib_dirs_glob, glob) Dir[glob].map {|f| f.tap(&Gem::UNTAINT) } # FIX our tests are broken, run w/ SAFE=1 end @@ -286,17 +286,17 @@ class Gem::BasicSpecification # for this spec. def lib_dirs_glob - dirs = if self.raw_require_paths - if self.raw_require_paths.size > 1 - "{#{self.raw_require_paths.join(",")}}" + dirs = if raw_require_paths + if raw_require_paths.size > 1 + "{#{raw_require_paths.join(",")}}" else - self.raw_require_paths.first + raw_require_paths.first end else "lib" # default value for require_paths for bundler/inline end - "#{self.full_gem_path}/#{dirs}".dup.tap(&Gem::UNTAINT) + "#{full_gem_path}/#{dirs}".dup.tap(&Gem::UNTAINT) end ## diff --git a/lib/rubygems/command.rb b/lib/rubygems/command.rb index 896bc95745..8bcfe2eb83 100644 --- a/lib/rubygems/command.rb +++ b/lib/rubygems/command.rb @@ -313,7 +313,7 @@ class Gem::Command options[:build_args] = build_args if options[:silent] - old_ui = self.ui + old_ui = ui self.ui = ui = Gem::SilentUI.new end diff --git a/lib/rubygems/commands/push_command.rb b/lib/rubygems/commands/push_command.rb index 7c5cb7a81a..95faebce23 100644 --- a/lib/rubygems/commands/push_command.rb +++ b/lib/rubygems/commands/push_command.rb @@ -29,7 +29,7 @@ The push command will use ~/.gem/credentials to authenticate to a server, but yo end def initialize - super "push", "Push a gem up to the gem server", :host => self.host + super "push", "Push a gem up to the gem server", :host => host @user_defined_host = false diff --git a/lib/rubygems/commands/yank_command.rb b/lib/rubygems/commands/yank_command.rb index f4e962f201..7b6870473c 100644 --- a/lib/rubygems/commands/yank_command.rb +++ b/lib/rubygems/commands/yank_command.rb @@ -61,7 +61,7 @@ data you will need to change them immediately and yank your gem. end def yank_gem(version, platform) - say "Yanking gem from #{self.host}..." + say "Yanking gem from #{host}..." args = [:delete, version, platform, "api/v1/gems/yank"] response = yank_api_request(*args) diff --git a/lib/rubygems/dependency.rb b/lib/rubygems/dependency.rb index 5d6aa63d79..67b26a33bb 100644 --- a/lib/rubygems/dependency.rb +++ b/lib/rubygems/dependency.rb @@ -74,10 +74,10 @@ class Gem::Dependency def inspect # :nodoc: if prerelease? "<%s type=%p name=%p requirements=%p prerelease=ok>" % - [self.class, self.type, self.name, requirement.to_s] + [self.class, type, name, requirement.to_s] else "<%s type=%p name=%p requirements=%p>" % - [self.class, self.type, self.name, requirement.to_s] + [self.class, type, name, requirement.to_s] end end @@ -168,16 +168,16 @@ class Gem::Dependency def ==(other) # :nodoc: Gem::Dependency === other && - self.name == other.name && - self.type == other.type && - self.requirement == other.requirement + name == other.name && + type == other.type && + requirement == other.requirement end ## # Dependencies are ordered by name. def <=>(other) - self.name <=> other.name + name <=> other.name end ## @@ -262,7 +262,7 @@ class Gem::Dependency end default = Gem::Requirement.default - self_req = self.requirement + self_req = requirement other_req = other.requirement return self.class.new name, self_req if other_req == default @@ -323,7 +323,7 @@ class Gem::Dependency end def to_spec - matches = self.to_specs.compact + matches = to_specs.compact active = matches.find(&:activated?) return active if active diff --git a/lib/rubygems/deprecate.rb b/lib/rubygems/deprecate.rb index c51d75a48d..535fe8d336 100644 --- a/lib/rubygems/deprecate.rb +++ b/lib/rubygems/deprecate.rb @@ -103,7 +103,7 @@ module Gem::Deprecate old = "_deprecated_#{name}" alias_method old, name define_method name do |*args, &block| - klass = self.is_a? Module + klass = is_a? Module target = klass ? "#{self}." : "#{self.class}#" msg = [ "NOTE: #{target}#{name} is deprecated", @@ -129,7 +129,7 @@ module Gem::Deprecate old = "_deprecated_#{name}" alias_method old, name define_method name do |*args, &block| - klass = self.is_a? Module + klass = is_a? Module target = klass ? "#{self}." : "#{self.class}#" msg = [ "NOTE: #{target}#{name} is deprecated", @@ -153,7 +153,7 @@ module Gem::Deprecate define_method "deprecation_warning" do msg = [ - "#{self.command} command is deprecated", + "#{command} command is deprecated", ". It will be removed in Rubygems #{version}.\n", ] diff --git a/lib/rubygems/gemcutter_utilities.rb b/lib/rubygems/gemcutter_utilities.rb index 3d72e28dbe..3e26ceb66c 100644 --- a/lib/rubygems/gemcutter_utilities.rb +++ b/lib/rubygems/gemcutter_utilities.rb @@ -120,7 +120,7 @@ module Gem::GemcutterUtilities end def update_scope(scope) - sign_in_host = self.host + sign_in_host = host pretty_host = pretty_host(sign_in_host) update_scope_params = { scope => true } @@ -146,7 +146,7 @@ module Gem::GemcutterUtilities # key. def sign_in(sign_in_host = nil, scope: nil) - sign_in_host ||= self.host + sign_in_host ||= host return if api_key pretty_host = pretty_host(sign_in_host) @@ -279,7 +279,7 @@ module Gem::GemcutterUtilities end def default_host? - self.host == Gem::DEFAULT_HOST + host == Gem::DEFAULT_HOST end def get_user_profile(email, password) diff --git a/lib/rubygems/remote_fetcher.rb b/lib/rubygems/remote_fetcher.rb index a3cb36e951..a1ceaa41dd 100644 --- a/lib/rubygems/remote_fetcher.rb +++ b/lib/rubygems/remote_fetcher.rb @@ -52,7 +52,7 @@ class Gem::RemoteFetcher # Cached RemoteFetcher instance. def self.fetcher - @fetcher ||= self.new Gem.configuration[:http_proxy] + @fetcher ||= new Gem.configuration[:http_proxy] end attr_accessor :headers @@ -147,7 +147,7 @@ class Gem::RemoteFetcher remote_gem_path = source_uri + "gems/#{gem_file_name}" - self.cache_update_path remote_gem_path, local_gem_path + cache_update_path remote_gem_path, local_gem_path rescue FetchError raise if spec.original_platform == spec.platform @@ -157,7 +157,7 @@ class Gem::RemoteFetcher remote_gem_path = source_uri + "gems/#{alternate_name}" - self.cache_update_path remote_gem_path, local_gem_path + cache_update_path remote_gem_path, local_gem_path end end when "file" then diff --git a/lib/rubygems/specification.rb b/lib/rubygems/specification.rb index d1079cc42c..35e599ed00 100644 --- a/lib/rubygems/specification.rb +++ b/lib/rubygems/specification.rb @@ -938,7 +938,7 @@ class Gem::Specification < Gem::BasicSpecification # Return full names of all specs in sorted order. def self.all_names - self._all.map(&:full_name) + _all.map(&:full_name) end ## @@ -973,7 +973,7 @@ class Gem::Specification < Gem::BasicSpecification # this resets the list of known specs. def self.dirs=(dirs) - self.reset + reset @@dirs = Array(dirs).map {|dir| File.join dir, "specifications" } end @@ -987,7 +987,7 @@ class Gem::Specification < Gem::BasicSpecification def self.each return enum_for(:each) unless block_given? - self._all.each do |x| + _all.each do |x| yield x end end @@ -1418,7 +1418,7 @@ class Gem::Specification < Gem::BasicSpecification # there are conflicts upon activation. def activate - other = Gem.loaded_specs[self.name] + other = Gem.loaded_specs[name] if other check_version_conflict other return false @@ -1429,7 +1429,7 @@ class Gem::Specification < Gem::BasicSpecification activate_dependencies add_self_to_load_path - Gem.loaded_specs[self.name] = self + Gem.loaded_specs[name] = self @activated = true @loaded = true @@ -1444,7 +1444,7 @@ class Gem::Specification < Gem::BasicSpecification def activate_dependencies unresolved = Gem::Specification.unresolved_deps - self.runtime_dependencies.each do |spec_dep| + runtime_dependencies.each do |spec_dep| if loaded = Gem.loaded_specs[spec_dep.name] next if spec_dep.matches_spec? loaded @@ -1458,7 +1458,7 @@ class Gem::Specification < Gem::BasicSpecification begin specs = spec_dep.to_specs rescue Gem::MissingSpecError => e - raise Gem::MissingSpecError.new(e.name, e.requirement, "at: #{self.spec_file}") + raise Gem::MissingSpecError.new(e.name, e.requirement, "at: #{spec_file}") end if specs.size == 1 @@ -1677,7 +1677,7 @@ class Gem::Specification < Gem::BasicSpecification def conflicts conflicts = {} - self.runtime_dependencies.each do |dep| + runtime_dependencies.each do |dep| spec = Gem.loaded_specs[dep.name] if spec && !spec.satisfies_requirement?(dep) (conflicts[spec] ||= []) << dep @@ -1703,7 +1703,7 @@ class Gem::Specification < Gem::BasicSpecification def has_conflicts? return true unless Gem.env_requirement(name).satisfied_by?(version) - self.dependencies.any? do |dep| + dependencies.any? do |dep| if dep.runtime? spec = Gem.loaded_specs[dep.name] spec && !spec.satisfies_requirement?(dep) @@ -1808,7 +1808,7 @@ class Gem::Specification < Gem::BasicSpecification Gem::Specification.each do |spec| deps = check_dev ? spec.dependencies : spec.runtime_dependencies deps.each do |dep| - if self.satisfies_requirement?(dep) + if satisfies_requirement?(dep) sats = [] find_all_satisfiers(dep) do |sat| sats << sat @@ -2251,7 +2251,7 @@ class Gem::Specification < Gem::BasicSpecification attributes.unshift :name attributes.each do |attr_name| - current_value = self.send attr_name + current_value = send attr_name current_value = current_value.sort if %i[files test_files].include? attr_name if current_value != default_value(attr_name) || self.class.required_attribute?(attr_name) @@ -2277,7 +2277,7 @@ class Gem::Specification < Gem::BasicSpecification # that is already loaded (+other+) def check_version_conflict(other) # :nodoc: - return if self.version == other.version + return if version == other.version # This gem is already loaded. If the currently loaded gem is not in the # list of candidate gems, then we have a version conflict. @@ -2285,7 +2285,7 @@ class Gem::Specification < Gem::BasicSpecification msg = "can't activate #{full_name}, already activated #{other.full_name}" e = Gem::LoadError.new msg - e.name = self.name + e.name = name raise e end @@ -2377,7 +2377,7 @@ class Gem::Specification < Gem::BasicSpecification # True if this gem has the same attributes as +other+. def same_attributes?(spec) - @@attributes.all? {|name, _default| self.send(name) == spec.send(name) } + @@attributes.all? {|name, _default| send(name) == spec.send(name) } end private :same_attributes? @@ -2514,7 +2514,7 @@ class Gem::Specification < Gem::BasicSpecification @@attributes.each do |attr_name| next if handled.include? attr_name - current_value = self.send(attr_name) + current_value = send(attr_name) if current_value != default_value(attr_name) || self.class.required_attribute?(attr_name) result << " s.#{attr_name} = #{ruby_code current_value}" end @@ -2706,7 +2706,7 @@ class Gem::Specification < Gem::BasicSpecification end nil_attributes.each do |attribute| - default = self.default_value attribute + default = default_value attribute value = case default when Time, Numeric, Symbol, true, false, nil then default -- cgit v1.2.3