summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHiroshi SHIBATA <[email protected]>2023-03-16 13:53:44 +0900
committerHiroshi SHIBATA <[email protected]>2023-03-17 18:50:55 +0900
commitf4b073ef7ad959c43b7d14acad2df49a5d056874 (patch)
tree4423be6ccaa43221d133f14d624c7dd52a51f6c7
parent4868cfcf1d8480ae13dc5e84c0e66dd44b950a89 (diff)
[rubygems/rubygems] util/rubocop -A --only Style/UnlessElse
https://github.com/rubygems/rubygems/commit/184c03270c
-rw-r--r--lib/rubygems/commands/check_command.rb6
-rw-r--r--lib/rubygems/commands/cleanup_command.rb6
-rw-r--r--lib/rubygems/commands/sources_command.rb18
-rw-r--r--lib/rubygems/compatibility.rb10
-rw-r--r--test/rubygems/test_gem_remote_fetcher.rb22
5 files changed, 31 insertions, 31 deletions
diff --git a/lib/rubygems/commands/check_command.rb b/lib/rubygems/commands/check_command.rb
index ff15fa11b0..4cf50ffc1e 100644
--- a/lib/rubygems/commands/check_command.rb
+++ b/lib/rubygems/commands/check_command.rb
@@ -47,14 +47,14 @@ class Gem::Commands::CheckCommand < Gem::Command
end
Gem::Validator.new.alien(gems).sort.each do |key, val|
- unless val.empty?
+ if val.empty?
+ say "#{key} is error-free" if Gem.configuration.verbose
+ else
say "#{key} has #{val.size} problems"
val.each do |error_entry|
say " #{error_entry.path}:"
say " #{error_entry.problem}"
end
- else
- say "#{key} is error-free" if Gem.configuration.verbose
end
say
end
diff --git a/lib/rubygems/commands/cleanup_command.rb b/lib/rubygems/commands/cleanup_command.rb
index 86c61bc336..0f53227d9a 100644
--- a/lib/rubygems/commands/cleanup_command.rb
+++ b/lib/rubygems/commands/cleanup_command.rb
@@ -116,12 +116,12 @@ If no gems are named all gems in GEM_HOME are cleaned.
end
def get_candidate_gems
- @candidate_gems = unless options[:args].empty?
+ @candidate_gems = if options[:args].empty?
+ Gem::Specification.to_a
+ else
options[:args].map do |gem_name|
Gem::Specification.find_all_by_name gem_name
end.flatten
- else
- Gem::Specification.to_a
end
end
diff --git a/lib/rubygems/commands/sources_command.rb b/lib/rubygems/commands/sources_command.rb
index 0ed5b4a8f8..aa2fdd9239 100644
--- a/lib/rubygems/commands/sources_command.rb
+++ b/lib/rubygems/commands/sources_command.rb
@@ -98,16 +98,16 @@ Do you want to add this insecure source?
path = Gem.spec_cache_dir
FileUtils.rm_rf path
- unless File.exist? path
- say "*** Removed specs cache ***"
- else
- unless File.writable? path
- say "*** Unable to remove source cache (write protected) ***"
- else
+ if File.exist? path
+ if File.writable? path
say "*** Unable to remove source cache ***"
+ else
+ say "*** Unable to remove source cache (write protected) ***"
end
terminate_interaction 1
+ else
+ say "*** Removed specs cache ***"
end
end
@@ -193,13 +193,13 @@ To remove a source use the --remove argument:
end
def remove_source(source_uri) # :nodoc:
- unless Gem.sources.include? source_uri
- say "source #{source_uri} not present in cache"
- else
+ if Gem.sources.include? source_uri
Gem.sources.delete source_uri
Gem.configuration.write
say "#{source_uri} removed from sources"
+ else
+ say "source #{source_uri} not present in cache"
end
end
diff --git a/lib/rubygems/compatibility.rb b/lib/rubygems/compatibility.rb
index d04ab6483d..0d9df56f8a 100644
--- a/lib/rubygems/compatibility.rb
+++ b/lib/rubygems/compatibility.rb
@@ -26,16 +26,16 @@ module Gem
rubylibdir
].freeze
- unless defined?(ConfigMap)
+ if defined?(ConfigMap)
+ RbConfigPriorities.each do |key|
+ ConfigMap[key.to_sym] = RbConfig::CONFIG[key]
+ end
+ else
##
# Configuration settings from ::RbConfig
ConfigMap = Hash.new do |cm, key|
cm[key] = RbConfig::CONFIG[key.to_s]
end
deprecate_constant(:ConfigMap)
- else
- RbConfigPriorities.each do |key|
- ConfigMap[key.to_sym] = RbConfig::CONFIG[key]
- end
end
end
diff --git a/test/rubygems/test_gem_remote_fetcher.rb b/test/rubygems/test_gem_remote_fetcher.rb
index 5b4498ca11..1ff14e28d9 100644
--- a/test/rubygems/test_gem_remote_fetcher.rb
+++ b/test/rubygems/test_gem_remote_fetcher.rb
@@ -205,12 +205,7 @@ PeIQQkFng2VVot/WAQbv3ePqWq07g1BBcwIBAg==
fetcher = Gem::RemoteFetcher.fetcher
fetcher.instance_variable_set :@test_data, data
- unless blow
- def fetcher.fetch_path(arg, *rest)
- @test_arg = arg
- @test_data
- end
- else
+ if blow
def fetcher.fetch_path(arg, *rest)
# OMG I'm such an ass
class << self; remove_method :fetch_path; end
@@ -221,6 +216,11 @@ PeIQQkFng2VVot/WAQbv3ePqWq07g1BBcwIBAg==
raise Gem::RemoteFetcher::FetchError.new("haha!", "")
end
+ else
+ def fetcher.fetch_path(arg, *rest)
+ @test_arg = arg
+ @test_data
+ end
end
fetcher
@@ -653,15 +653,15 @@ PeIQQkFng2VVot/WAQbv3ePqWq07g1BBcwIBAg==
def fetcher.request(uri, request_class, last_modified = nil)
url = "http://gems.example.com/redirect"
- unless defined? @requested
- @requested = true
- res = Net::HTTPMovedPermanently.new nil, 301, nil
- res.add_field "Location", url
- else
+ if defined? @requested
res = Net::HTTPOK.new nil, 200, nil
def res.body
"real_path"
end
+ else
+ @requested = true
+ res = Net::HTTPMovedPermanently.new nil, 301, nil
+ res.add_field "Location", url
end
res
end