[rubygems/rubygems] util/rubocop -A --only Style/Next

https://github.com/rubygems/rubygems/commit/e5868e92f7
This commit is contained in:
Hiroshi SHIBATA 2023-03-22 13:26:37 +09:00
parent bec069b0ca
commit 0eef33e113
Notes: git 2023-03-23 08:19:23 +00:00
9 changed files with 89 additions and 103 deletions

View File

@ -395,7 +395,7 @@ class Gem::Command
def check_deprecated_options(options) def check_deprecated_options(options)
options.each do |option| options.each do |option|
if option_is_deprecated?(option) next unless option_is_deprecated?(option)
deprecation = @deprecated_options[command][option] deprecation = @deprecated_options[command][option]
version_to_expire = deprecation["rg_version_to_expire"] version_to_expire = deprecation["rg_version_to_expire"]
@ -412,7 +412,6 @@ class Gem::Command
alert_warning(deprecate_option_msg) alert_warning(deprecate_option_msg)
end end
end end
end
## ##
# Merge a set of command options with the set of default options (without # Merge a set of command options with the set of default options (without

View File

@ -89,13 +89,12 @@ use with other commands.
def display_pipe(specs) # :nodoc: def display_pipe(specs) # :nodoc:
specs.each do |spec| specs.each do |spec|
unless spec.dependencies.empty? next if spec.dependencies.empty?
spec.dependencies.sort_by(&:name).each do |dep| spec.dependencies.sort_by(&:name).each do |dep|
say "#{dep.name} --version '#{dep.requirement}'" say "#{dep.name} --version '#{dep.requirement}'"
end end
end end
end end
end
def display_readable(specs, reverse) # :nodoc: def display_readable(specs, reverse) # :nodoc:
response = String.new response = String.new

View File

@ -167,7 +167,7 @@ that is a dependency of an existing gem. You can use the
gems_to_uninstall = {} gems_to_uninstall = {}
deps.each do |dep| deps.each do |dep|
unless gems_to_uninstall[dep.name] next if gems_to_uninstall[dep.name]
gems_to_uninstall[dep.name] = true gems_to_uninstall[dep.name] = true
unless original_gem_version[dep.name] == Gem::Requirement.default unless original_gem_version[dep.name] == Gem::Requirement.default
@ -177,7 +177,6 @@ that is a dependency of an existing gem. You can use the
uninstall_gem(dep.name) uninstall_gem(dep.name)
end end
end end
end
def uninstall_gem(gem_name) def uninstall_gem(gem_name)
uninstall(gem_name) uninstall(gem_name)

View File

@ -35,13 +35,12 @@ module Kernel
start += 1 start += 1
if path = loc.path next unless path = loc.path
unless path.start_with?(rubygems_path, "<internal:") unless path.start_with?(rubygems_path, "<internal:")
# Non-rubygems frames # Non-rubygems frames
uplevel -= 1 uplevel -= 1
end end
end end
end
kw[:uplevel] = start kw[:uplevel] = start
end end

View File

@ -354,18 +354,17 @@ class Gem::Installer
def run_pre_install_hooks # :nodoc: def run_pre_install_hooks # :nodoc:
Gem.pre_install_hooks.each do |hook| Gem.pre_install_hooks.each do |hook|
if hook.call(self) == false next unless hook.call(self) == false
location = " at #{$1}" if hook.inspect =~ /[ @](.*:\d+)/ location = " at #{$1}" if hook.inspect =~ /[ @](.*:\d+)/
message = "pre-install hook#{location} failed for #{spec.full_name}" message = "pre-install hook#{location} failed for #{spec.full_name}"
raise Gem::InstallError, message raise Gem::InstallError, message
end end
end end
end
def run_post_build_hooks # :nodoc: def run_post_build_hooks # :nodoc:
Gem.post_build_hooks.each do |hook| Gem.post_build_hooks.each do |hook|
if hook.call(self) == false next unless hook.call(self) == false
FileUtils.rm_rf gem_dir FileUtils.rm_rf gem_dir
location = " at #{$1}" if hook.inspect =~ /[ @](.*:\d+)/ location = " at #{$1}" if hook.inspect =~ /[ @](.*:\d+)/
@ -374,7 +373,6 @@ class Gem::Installer
raise Gem::InstallError, message raise Gem::InstallError, message
end end
end end
end
def run_post_install_hooks # :nodoc: def run_post_install_hooks # :nodoc:
Gem.post_install_hooks.each do |hook| Gem.post_install_hooks.each do |hook|

View File

@ -43,12 +43,11 @@ class Gem::Resolver::IndexSet < Gem::Resolver::Set
name = req.dependency.name name = req.dependency.name
@all[name].each do |uri, n| @all[name].each do |uri, n|
if req.match? n, @prerelease next unless req.match? n, @prerelease
res << Gem::Resolver::IndexSpecification.new( res << Gem::Resolver::IndexSpecification.new(
self, n.name, n.version, uri, n.platform self, n.name, n.version, uri, n.platform
) )
end end
end
res res
end end

View File

@ -79,7 +79,7 @@ class Gem::Source::Local < Gem::Source
found = [] found = []
@specs.each do |n, data| @specs.each do |n, data|
if n.name == gem_name next unless n.name == gem_name
s = data[1].spec s = data[1].spec
if version.satisfied_by?(s.version) if version.satisfied_by?(s.version)
@ -90,7 +90,6 @@ class Gem::Source::Local < Gem::Source
end end
end end
end end
end
found.max_by(&:version) found.max_by(&:version)
end end

View File

@ -1808,7 +1808,7 @@ class Gem::Specification < Gem::BasicSpecification
Gem::Specification.each do |spec| Gem::Specification.each do |spec|
deps = check_dev ? spec.dependencies : spec.runtime_dependencies deps = check_dev ? spec.dependencies : spec.runtime_dependencies
deps.each do |dep| deps.each do |dep|
if satisfies_requirement?(dep) next unless satisfies_requirement?(dep)
sats = [] sats = []
find_all_satisfiers(dep) do |sat| find_all_satisfiers(dep) do |sat|
sats << sat sats << sat
@ -1816,7 +1816,6 @@ class Gem::Specification < Gem::BasicSpecification
out << [spec, dep, sats] out << [spec, dep, sats]
end end
end end
end
out out
end end
@ -2253,7 +2252,7 @@ class Gem::Specification < Gem::BasicSpecification
attributes.each do |attr_name| attributes.each do |attr_name|
current_value = send attr_name current_value = send attr_name
current_value = current_value.sort if [:files, :test_files].include? attr_name current_value = current_value.sort if [:files, :test_files].include? attr_name
if current_value != default_value(attr_name) || next unless current_value != default_value(attr_name) ||
self.class.required_attribute?(attr_name) self.class.required_attribute?(attr_name)
q.text "s.#{attr_name} = " q.text "s.#{attr_name} = "
@ -2270,7 +2269,6 @@ class Gem::Specification < Gem::BasicSpecification
end end
end end
end end
end
## ##
# Raise an exception if the version of this spec conflicts with the one # Raise an exception if the version of this spec conflicts with the one
@ -2609,13 +2607,12 @@ class Gem::Specification < Gem::BasicSpecification
ensure ensure
trail.pop trail.pop
end end
unless result == :next next if result == :next
spec_name = dep_spec.name spec_name = dep_spec.name
dep_spec.traverse(trail, visited, &block) unless dep_spec.traverse(trail, visited, &block) unless
trail.any? {|s| s.name == spec_name } trail.any? {|s| s.name == spec_name }
end end
end end
end
ensure ensure
trail.pop trail.pop
end end

View File

@ -141,13 +141,12 @@ class Gem::SpecificationPolicy
error "#{entry} value is too large (#{value.size} > 1024)" error "#{entry} value is too large (#{value.size} > 1024)"
end end
if METADATA_LINK_KEYS.include? key next unless METADATA_LINK_KEYS.include? key
if value !~ VALID_URI_PATTERN if value !~ VALID_URI_PATTERN
error "#{entry} has invalid link: #{value.inspect}" error "#{entry} has invalid link: #{value.inspect}"
end end
end end
end end
end
## ##
# Checks that no duplicate dependencies are specified. # Checks that no duplicate dependencies are specified.
@ -196,7 +195,7 @@ duplicate dependency on #{dep}, (#{prev.requirement}) use:
!version.prerelease? && [">", ">="].include?(op) !version.prerelease? && [">", ">="].include?(op)
end end
if open_ended next unless open_ended
op, dep_version = dep.requirement.requirements.first op, dep_version = dep.requirement.requirements.first
segments = dep_version.segments segments = dep_version.segments
@ -218,7 +217,6 @@ duplicate dependency on #{dep}, (#{prev.requirement}) use:
warning_messages << ["open-ended dependency on #{dep} is not recommended", recommendation].join("\n") + "\n" warning_messages << ["open-ended dependency on #{dep} is not recommended", recommendation].join("\n") + "\n"
end end
end
if warning_messages.any? if warning_messages.any?
warning_messages.each {|warning_message| warning warning_message } warning_messages.each {|warning_message| warning warning_message }
end end
@ -368,7 +366,7 @@ duplicate dependency on #{dep}, (#{prev.requirement}) use:
licenses = @specification.licenses licenses = @specification.licenses
licenses.each do |license| licenses.each do |license|
unless Gem::Licenses.match?(license) next if Gem::Licenses.match?(license)
suggestions = Gem::Licenses.suggestions(license) suggestions = Gem::Licenses.suggestions(license)
message = <<-WARNING message = <<-WARNING
license value '#{license}' is invalid. Use a license identifier from license value '#{license}' is invalid. Use a license identifier from
@ -377,7 +375,6 @@ http://spdx.org/licenses or '#{Gem::Licenses::NONSTANDARD}' for a nonstandard li
message += "Did you mean #{suggestions.map {|s| "'#{s}'" }.join(", ")}?\n" unless suggestions.nil? message += "Did you mean #{suggestions.map {|s| "'#{s}'" }.join(", ")}?\n" unless suggestions.nil?
warning(message) warning(message)
end end
end
warning <<-WARNING if licenses.empty? warning <<-WARNING if licenses.empty?
licenses is empty, but is recommended. Use a license identifier from licenses is empty, but is recommended. Use a license identifier from