summaryrefslogtreecommitdiff
path: root/lib/rubygems
diff options
context:
space:
mode:
authorHiroshi SHIBATA <hsbt@ruby-lang.org>2023-03-16 13:53:44 +0900
committerHiroshi SHIBATA <hsbt@ruby-lang.org>2023-03-17 18:50:55 +0900
commitf4b073ef7ad959c43b7d14acad2df49a5d056874 (patch)
tree4423be6ccaa43221d133f14d624c7dd52a51f6c7 /lib/rubygems
parent4868cfcf1d8480ae13dc5e84c0e66dd44b950a89 (diff)
[rubygems/rubygems] util/rubocop -A --only Style/UnlessElse
https://github.com/rubygems/rubygems/commit/184c03270c
Diffstat (limited to 'lib/rubygems')
-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
4 files changed, 20 insertions, 20 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