From ba9dcdab3669f11b2e265712ceb43227c366fc3b Mon Sep 17 00:00:00 2001 From: David Rodríguez Date: Tue, 24 Mar 2020 19:51:43 +0100 Subject: [rubygems/rubygems] Enable Style/PercentLiteralDelimiters cop in rubygems So it matches the style used by bundler. https://github.com/rubygems/rubygems/commit/ab0580fd65 --- lib/rubygems.rb | 2 +- lib/rubygems/commands/setup_command.rb | 2 +- lib/rubygems/ext/ext_conf_builder.rb | 2 +- lib/rubygems/safe_yaml.rb | 8 ++++---- lib/rubygems/server.rb | 2 +- lib/rubygems/source/git.rb | 4 ++-- lib/rubygems/specification.rb | 2 +- lib/rubygems/test_case.rb | 4 ++-- lib/rubygems/test_utilities.rb | 4 ++-- lib/rubygems/util/licenses.rb | 8 ++++---- 10 files changed, 19 insertions(+), 19 deletions(-) (limited to 'lib') diff --git a/lib/rubygems.rb b/lib/rubygems.rb index 9bd4e9be20..73321ec47b 100644 --- a/lib/rubygems.rb +++ b/lib/rubygems.rb @@ -1011,7 +1011,7 @@ An Array (#{env.inspect}) was passed in from #{caller[3]} def self.suffixes @suffixes ||= ['', '.rb', - *%w(DLEXT DLEXT2).map do |key| + *%w[DLEXT DLEXT2].map do |key| val = RbConfig::CONFIG[key] next unless val and not val.empty? ".#{val}" diff --git a/lib/rubygems/commands/setup_command.rb b/lib/rubygems/commands/setup_command.rb index d67caca91c..679803c338 100644 --- a/lib/rubygems/commands/setup_command.rb +++ b/lib/rubygems/commands/setup_command.rb @@ -546,7 +546,7 @@ abort "#{deprecation_message}" next unless Gem.win_platform? File.open "#{old_bin_path}.bat", 'w' do |fp| - fp.puts %{@ECHO.#{deprecation_message}} + fp.puts %(@ECHO.#{deprecation_message}) end end end diff --git a/lib/rubygems/ext/ext_conf_builder.rb b/lib/rubygems/ext/ext_conf_builder.rb index 88be7ecfe8..d06e923a30 100644 --- a/lib/rubygems/ext/ext_conf_builder.rb +++ b/lib/rubygems/ext/ext_conf_builder.rb @@ -27,7 +27,7 @@ class Gem::Ext::ExtConfBuilder < Gem::Ext::Builder # Details: https://github.com/rubygems/rubygems/issues/977#issuecomment-171544940 tmp_dest = get_relative_path(tmp_dest) - Tempfile.open %w"siteconf .rb", "." do |siteconf| + Tempfile.open %w[siteconf .rb], "." do |siteconf| siteconf.puts "require 'rbconfig'" siteconf.puts "dest_path = #{tmp_dest.dump}" %w[sitearchdir sitelibdir].each do |dir| diff --git a/lib/rubygems/safe_yaml.rb b/lib/rubygems/safe_yaml.rb index 3540fd74dd..29312ad5a1 100644 --- a/lib/rubygems/safe_yaml.rb +++ b/lib/rubygems/safe_yaml.rb @@ -7,7 +7,7 @@ module Gem # Psych.safe_load module SafeYAML - PERMITTED_CLASSES = %w( + PERMITTED_CLASSES = %w[ Symbol Time Date @@ -19,12 +19,12 @@ module Gem Gem::Version::Requirement YAML::Syck::DefaultKey Syck::DefaultKey - ).freeze + ].freeze - PERMITTED_SYMBOLS = %w( + PERMITTED_SYMBOLS = %w[ development runtime - ).freeze + ].freeze if ::YAML.respond_to? :safe_load def self.safe_load(input) diff --git a/lib/rubygems/server.rb b/lib/rubygems/server.rb index 83d7cf5abc..b2130852e0 100644 --- a/lib/rubygems/server.rb +++ b/lib/rubygems/server.rb @@ -573,7 +573,7 @@ div.method-source-code pre { color: #ffdead; overflow: hidden; } add_date res case req.request_uri.path - when %r|^/quick/(Marshal.#{Regexp.escape Gem.marshal_version}/)?(.*?)\.gemspec\.rz$| then + when %r{^/quick/(Marshal.#{Regexp.escape Gem.marshal_version}/)?(.*?)\.gemspec\.rz$} then marshal_format, full_name = $1, $2 specs = Gem::Specification.find_all_by_full_name(full_name) diff --git a/lib/rubygems/source/git.rb b/lib/rubygems/source/git.rb index 0b8a4339cc..ec2c371fa9 100644 --- a/lib/rubygems/source/git.rb +++ b/lib/rubygems/source/git.rb @@ -228,8 +228,8 @@ class Gem::Source::Git < Gem::Source require 'digest' # required here to avoid deadlocking in Gem.activate_bin_path (because digest is a gem on 2.5+) normalized = - if @repository =~ %r%^\w+://(\w+@)?% - uri = URI(@repository).normalize.to_s.sub %r%/$%,'' + if @repository =~ %r{^\w+://(\w+@)?} + uri = URI(@repository).normalize.to_s.sub %r{/$},'' uri.sub(/\A(\w+)/) { $1.downcase } else @repository diff --git a/lib/rubygems/specification.rb b/lib/rubygems/specification.rb index 3181303c30..3a2a6090fd 100644 --- a/lib/rubygems/specification.rb +++ b/lib/rubygems/specification.rb @@ -2188,7 +2188,7 @@ class Gem::Specification < Gem::BasicSpecification attributes.each do |attr_name| current_value = self.send attr_name - current_value = current_value.sort if %i(files test_files).include? attr_name + current_value = current_value.sort if %i[files test_files].include? attr_name if current_value != default_value(attr_name) or self.class.required_attribute? attr_name diff --git a/lib/rubygems/test_case.rb b/lib/rubygems/test_case.rb index ebfe979a1b..27b70222c9 100644 --- a/lib/rubygems/test_case.rb +++ b/lib/rubygems/test_case.rb @@ -576,7 +576,7 @@ class Gem::TestCase < (defined?(Minitest::Test) ? Minitest::Test : MiniTest::Uni end def in_path?(executable) # :nodoc: - return true if %r%\A([A-Z]:|/)% =~ executable and File.exist? executable + return true if %r{\A([A-Z]:|/)} =~ executable and File.exist? executable ENV['PATH'].split(File::PATH_SEPARATOR).any? do |directory| File.exist? File.join directory, executable @@ -1286,7 +1286,7 @@ Also, a list: def escape_path(*path) path = File.join(*path) - if %r'\A[-+:/=@,.\w]+\z' =~ path + if %r{\A[-+:/=@,.\w]+\z} =~ path path else "\"#{path.gsub(/[`$"]/, '\\&')}\"" diff --git a/lib/rubygems/test_utilities.rb b/lib/rubygems/test_utilities.rb index 69ff05370e..6ae3c0e986 100644 --- a/lib/rubygems/test_utilities.rb +++ b/lib/rubygems/test_utilities.rb @@ -49,7 +49,7 @@ class Gem::FakeFetcher path = path.to_s @paths << path - raise ArgumentError, 'need full URI' unless path =~ %r'^https?://' + raise ArgumentError, 'need full URI' unless path =~ %r{^https?://} unless @data.key? path raise Gem::RemoteFetcher::FetchError.new("no data for #{path}", path) @@ -121,7 +121,7 @@ class Gem::FakeFetcher path = path.to_s @paths << path - raise ArgumentError, 'need full URI' unless path =~ %r'^http://' + raise ArgumentError, 'need full URI' unless path =~ %r{^http://} unless @data.key? path raise Gem::RemoteFetcher::FetchError.new("no data for #{path}", path) diff --git a/lib/rubygems/util/licenses.rb b/lib/rubygems/util/licenses.rb index f23be157b9..5b82667785 100644 --- a/lib/rubygems/util/licenses.rb +++ b/lib/rubygems/util/licenses.rb @@ -9,7 +9,7 @@ class Gem::Licenses # Software Package Data Exchange (SPDX) standard open-source software # license identifiers - LICENSE_IDENTIFIERS = %w( + LICENSE_IDENTIFIERS = %w[ 0BSD AAL ADSL @@ -379,10 +379,10 @@ class Gem::Licenses xinetd xpp zlib-acknowledgement - ).freeze + ].freeze # exception identifiers - EXCEPTION_IDENTIFIERS = %w( + EXCEPTION_IDENTIFIERS = %w[ 389-exception Autoconf-exception-2.0 Autoconf-exception-3.0 @@ -410,7 +410,7 @@ class Gem::Licenses mif-exception openvpn-openssl-exception u-boot-exception-2.0 - ).freeze + ].freeze REGEXP = %r{ \A -- cgit v1.2.3