diff options
author | Hiroshi SHIBATA <[email protected]> | 2023-04-04 12:03:13 +0900 |
---|---|---|
committer | git <[email protected]> | 2023-04-04 12:20:43 +0000 |
commit | a881b33818b101ad097cd0158afda11b6c24f1fc () | |
tree | 73111721667233a91e214e4df703d91ab19cfded /lib | |
parent | a78e0ca968115cbf57228cf2c026d2e21534dc7b (diff) |
[rubygems/rubygems] util/rubocop -A --only Performance/RegexpMatch
https://.com/rubygems/rubygems/commit/52ae4452c2
-rw-r--r-- | lib/rubygems.rb | 4 | ||||
-rw-r--r-- | lib/rubygems/command.rb | 2 | ||||
-rw-r--r-- | lib/rubygems/commands/unpack_command.rb | 4 | ||||
-rw-r--r-- | lib/rubygems/config_file.rb | 4 | ||||
-rw-r--r-- | lib/rubygems/dependency_installer.rb | 2 | ||||
-rw-r--r-- | lib/rubygems/doctor.rb | 2 | ||||
-rw-r--r-- | lib/rubygems/ext/rake_builder.rb | 2 | ||||
-rw-r--r-- | lib/rubygems/installer.rb | 8 | ||||
-rw-r--r-- | lib/rubygems/local_remote_options.rb | 2 | ||||
-rw-r--r-- | lib/rubygems/package/tar_header.rb | 4 | ||||
-rw-r--r-- | lib/rubygems/path_support.rb | 2 | ||||
-rw-r--r-- | lib/rubygems/platform.rb | 2 | ||||
-rw-r--r-- | lib/rubygems/remote_fetcher.rb | 2 | ||||
-rw-r--r-- | lib/rubygems/resolver.rb | 2 | ||||
-rw-r--r-- | lib/rubygems/specification_policy.rb | 12 | ||||
-rw-r--r-- | lib/rubygems/uri_formatter.rb | 2 | ||||
-rw-r--r-- | lib/rubygems/version.rb | 2 |
17 files changed, 29 insertions, 29 deletions
@@ -795,7 +795,7 @@ An Array (#{env.inspect}) was passed in from #{caller[3]} if @ruby.nil? @ruby = RbConfig.ruby - @ruby = "\"#{@ruby}\"" if @ruby =~ /\s/ end @ruby @@ -1008,7 +1008,7 @@ An Array (#{env.inspect}) was passed in from #{caller[3]} # Skip older versions of the GemCutter plugin: Its commands are in # RubyGems proper now. - next if plugin =~ /gemcutter-0\.[0-3]/ begin load plugin @@ -457,7 +457,7 @@ class Gem::Command until extra.empty? do ex = [] ex << extra.shift - ex << extra.shift if extra.first.to_s =~ /^[^-]/ result << ex if handles?(ex) end @@ -151,7 +151,7 @@ command help for an example. # source directories? def get_path(dependency) - return dependency.name if dependency.name =~ /\.gem$/i specs = dependency.matching_specs @@ -160,7 +160,7 @@ command help for an example. return Gem::RemoteFetcher.fetcher.download_to_cache(dependency) unless selected - return unless dependency.name =~ /^#{selected.name}$/i # We expect to find (basename).gem in the 'cache' directory. Furthermore, # the name match must be exact (ignoring case). @@ -483,7 +483,7 @@ if you believe they were disclosed to a third party. @hash.each do |key, value| key = key.to_s - next if key =~ re yaml_hash[key.to_s] = value end @@ -534,7 +534,7 @@ if you believe they were disclosed to a third party. need_config_file_name = false elsif arg =~ /^--config-file=(.*)/ @config_file_name = $1 - elsif arg =~ /^--config-file$/ need_config_file_name = true end end @@ -291,7 +291,7 @@ class Gem::DependencyInstaller src = Gem::Source::SpecificFile.new dep_or_name installer_set.add_local dep_or_name, src.spec, src version = src.spec.version if version == Gem::Requirement.default - elsif dep_or_name =~ /\.gem$/ Dir[dep_or_name].each do |name| src = Gem::Source::SpecificFile.new name installer_set.add_local dep_or_name, src.spec, src @@ -111,7 +111,7 @@ class Gem::Doctor basename = File.basename(child, extension) next if installed_specs.include? basename - next if /^rubygems-\d/ =~ basename next if sub_directory == "specifications" && basename == "default" next if sub_directory == "plugins" && Gem.plugin_suffix_regexp =~ (basename) @@ -8,7 +8,7 @@ class Gem::Ext::RakeBuilder < Gem::Ext::Builder def self.build(extension, dest_path, results, args=[], lib_dir=nil, extension_dir=Dir.pwd) - if File.basename(extension) =~ /mkrf_conf/i run([Gem.ruby, File.basename(extension), *args], results, class_name, extension_dir) end @@ -230,7 +230,7 @@ class Gem::Installer end end - next unless line =~ shebang io.gets # blankline @@ -714,7 +714,7 @@ class Gem::Installer end def verify_spec - unless spec.name =~ Gem::Specification::VALID_NAME_PATTERN raise Gem::InstallError, "#{spec} has an invalid name" end @@ -726,11 +726,11 @@ class Gem::Installer raise Gem::InstallError, "#{spec} has an invalid extensions" end - if spec.platform.to_s =~ /\R/ raise Gem::InstallError, "#{spec.platform} is an invalid platform" end - unless spec.specification_version.to_s =~ /\A\d+\z/ raise Gem::InstallError, "#{spec} has an invalid specification_version" end @@ -103,7 +103,7 @@ module Gem::LocalRemoteOptions add_option(:"Local/Remote", "-s", "--source URL", URI::HTTP, "Append URL to list of remote gem sources") do |source, options| - source << "/" if source !~ /\/\z/ if options.delete :sources_cleared Gem.sources = [source] @@ -127,7 +127,7 @@ class Gem::Package::TarHeader end def self.strict_oct(str) - return str.strip.oct if str.strip =~ /\A[0-7]*\z/ raise ArgumentError, "#{str.inspect} is not an octal string" end @@ -137,7 +137,7 @@ class Gem::Package::TarHeader # \ff flags a negative 256-based number # In case we have a match, parse it as a signed binary value # in big-endian order, except that the high-order bit is ignored. - return str.unpack("N2").last if str =~ /\A[\x80\xff]/n strict_oct(str) end @@ -53,7 +53,7 @@ class Gem::PathSupport gem_path = gpaths.split(Gem.path_separator) # Handle the path_separator being set to a regexp, which will cause # end_with? to error - if gpaths =~ /#{Gem.path_separator}\z/ gem_path += default_path end @@ -14,7 +14,7 @@ class Gem::Platform def self.local arch = RbConfig::CONFIG["arch"] - arch = "#{arch}_60" if arch =~ /mswin(?:32|64)$/ @local ||= new(arch) end @@ -136,7 +136,7 @@ class Gem::RemoteFetcher scheme = source_uri.scheme # URI.parse gets confused by MS Windows paths with forward slashes. - scheme = nil if scheme =~ /^[a-z]$/i # REFACTOR: split this up and dis on scheme (eg download_http) # REFACTOR: be sure to clean up fake fetcher when you do this... cleaner @@ -247,7 +247,7 @@ class Gem::Resolver sources.each do |source| groups[source]. - sort_by {|spec| [spec.version, spec.platform =~ Gem::Platform.local ? 1 : 0] }. map {|spec| ActivationRequest.new spec, dependency }. each {|activation_request| activation_requests << activation_request } end @@ -144,7 +144,7 @@ class Gem::SpecificationPolicy end next unless METADATA_LINK_KEYS.include? key - if value !~ VALID_URI_PATTERN error "#{entry} has invalid link: #{value.inspect}" end end @@ -279,11 +279,11 @@ duplicate dependency on #{dep}, (#{prev.requirement}) use: if !name.is_a?(String) error "invalid value for attribute name: \"#{name.inspect}\" must be a string" - elsif name !~ /[a-zA-Z]/ error "invalid value for attribute name: #{name.dump} must include at least one letter" - elsif name !~ VALID_NAME_PATTERN error "invalid value for attribute name: #{name.dump} can only include letters, numbers, dashes, and underscores" - elsif name =~ SPECIAL_CHARACTERS error "invalid value for attribute name: #{name.dump} can not begin with a period, dash, or underscore" end end @@ -397,11 +397,11 @@ http://spdx.org/licenses or '#{Gem::Licenses::NONSTANDARD}' for a nonstandard li error "#{LAZY} is not an email" end - if @specification.description =~ LAZY_PATTERN error "#{LAZY} is not a description" end - if @specification.summary =~ LAZY_PATTERN error "#{LAZY} is not a summary" end @@ -34,7 +34,7 @@ class Gem::UriFormatter # Normalize the URI by adding "http://" if it is missing. def normalize - @uri =~ /^(https?|ftp|file):/i ? @uri : "http://#{@uri}" end ## @@ -405,7 +405,7 @@ class Gem::Version # since this version object is cached in @@all, its @segments should be frozen @segments ||= @version.scan(/[0-9]+|[a-z]+/i).map do |s| - /^\d+$/ =~ s ? s.to_i : s end.freeze end |