ruby-changes:60569
From: David <ko1@a...>
Date: Mon, 30 Mar 2020 13:00:57 +0900 (JST)
Subject: [ruby-changes:60569] ba9dcdab36 (master): [rubygems/rubygems] Enable Style/PercentLiteralDelimiters cop in rubygems
https://git.ruby-lang.org/ruby.git/commit/?id=ba9dcdab36 From ba9dcdab3669f11b2e265712ceb43227c366fc3b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20Rodr=C3=ADguez?= <deivid.rodriguez@r...> 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 diff --git a/lib/rubygems.rb b/lib/rubygems.rb index 9bd4e9b..73321ec 100644 --- a/lib/rubygems.rb +++ b/lib/rubygems.rb @@ -1011,7 +1011,7 @@ An Array (#{env.inspect}) was passed in from #{caller[3]} https://github.com/ruby/ruby/blob/trunk/lib/rubygems.rb#L1011 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 d67caca..679803c 100644 --- a/lib/rubygems/commands/setup_command.rb +++ b/lib/rubygems/commands/setup_command.rb @@ -546,7 +546,7 @@ abort "#{deprecation_message}" https://github.com/ruby/ruby/blob/trunk/lib/rubygems/commands/setup_command.rb#L546 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 88be7ec..d06e923 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 https://github.com/ruby/ruby/blob/trunk/lib/rubygems/ext/ext_conf_builder.rb#L27 # 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 3540fd7..29312ad 100644 --- a/lib/rubygems/safe_yaml.rb +++ b/lib/rubygems/safe_yaml.rb @@ -7,7 +7,7 @@ module Gem https://github.com/ruby/ruby/blob/trunk/lib/rubygems/safe_yaml.rb#L7 # Psych.safe_load module SafeYAML - PERMITTED_CLASSES = %w( + PERMITTED_CLASSES = %w[ Symbol Time Date @@ -19,12 +19,12 @@ module Gem https://github.com/ruby/ruby/blob/trunk/lib/rubygems/safe_yaml.rb#L19 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 83d7cf5..b213085 100644 --- a/lib/rubygems/server.rb +++ b/lib/rubygems/server.rb @@ -573,7 +573,7 @@ div.method-source-code pre { color: #ffdead; overflow: hidden; } https://github.com/ruby/ruby/blob/trunk/lib/rubygems/server.rb#L573 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 0b8a433..ec2c371 100644 --- a/lib/rubygems/source/git.rb +++ b/lib/rubygems/source/git.rb @@ -228,8 +228,8 @@ class Gem::Source::Git < Gem::Source https://github.com/ruby/ruby/blob/trunk/lib/rubygems/source/git.rb#L228 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 3181303..3a2a609 100644 --- a/lib/rubygems/specification.rb +++ b/lib/rubygems/specification.rb @@ -2188,7 +2188,7 @@ class Gem::Specification < Gem::BasicSpecification https://github.com/ruby/ruby/blob/trunk/lib/rubygems/specification.rb#L2188 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 ebfe979..27b7022 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 https://github.com/ruby/ruby/blob/trunk/lib/rubygems/test_case.rb#L576 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: https://github.com/ruby/ruby/blob/trunk/lib/rubygems/test_case.rb#L1286 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 69ff053..6ae3c0e 100644 --- a/lib/rubygems/test_utilities.rb +++ b/lib/rubygems/test_utilities.rb @@ -49,7 +49,7 @@ class Gem::FakeFetcher https://github.com/ruby/ruby/blob/trunk/lib/rubygems/test_utilities.rb#L49 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 https://github.com/ruby/ruby/blob/trunk/lib/rubygems/test_utilities.rb#L121 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 f23be15..5b82667 100644 --- a/lib/rubygems/util/licenses.rb +++ b/lib/rubygems/util/licenses.rb @@ -9,7 +9,7 @@ class Gem::Licenses https://github.com/ruby/ruby/blob/trunk/lib/rubygems/util/licenses.rb#L9 # 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 https://github.com/ruby/ruby/blob/trunk/lib/rubygems/util/licenses.rb#L379 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 https://github.com/ruby/ruby/blob/trunk/lib/rubygems/util/licenses.rb#L410 mif-exception openvpn-openssl-exception u-boot-exception-2.0 - ).freeze + ].freeze REGEXP = %r{ \A diff --git a/test/rubygems/test_gem.rb b/test/rubygems/test_gem.rb index fd9b360..0c7e0f7 100644 --- a/test/rubygems/test_gem.rb +++ b/test/rubygems/test_gem.rb @@ -42,12 +42,12 @@ class TestGem < Gem::TestCase https://github.com/ruby/ruby/blob/trunk/test/rubygems/test_gem.rb#L42 a1.activate - assert_equal %w(a-1), loaded_spec_names + assert_equal %w[a-1], loaded_spec_names assert_equal ["b (> 0)"], unresolved_names Gem.finish_resolve - assert_equal %w(a-1 b-2 c-2), loaded_spec_names + assert_equal %w[a-1 b-2 c-2], loaded_spec_names assert_equal [], unresolved_names end end @@ -66,12 +66,12 @@ class TestGem < Gem::TestCase https://github.com/ruby/ruby/blob/trunk/test/rubygems/test_gem.rb#L66 a1.activate - assert_equal %w(a-1), loaded_spec_names + assert_equal %w[a-1], loaded_spec_names assert_equal ["b (> 0)", "d (> 0)"], unresolved_names Gem.finish_resolve - assert_equal %w(a-1 b-1 c-1 d-2), loaded_spec_names + assert_equal %w[a-1 b-1 c-1 d-2], loaded_spec_names assert_equal [], unresolved_names end end @@ -89,12 +89,12 @@ class TestGem < Gem::TestCase https://github.com/ruby/ruby/blob/trunk/test/rubygems/test_gem.rb#L89 a1.activate c1.activate - assert_equal %w(a-1 c-1), loaded_spec_names + assert_equal %w[a-1 c-1], loaded_spec_names assert_equal ["b (> 0)"], unresolved_names Gem.finish_resolve - assert_equal %w(a-1 b-1 c-1), loaded_spec_names + assert_equal %w[a-1 b-1 c-1], loaded_spec_names assert_equal [], unresolved_names end end @@ -299,7 +299,7 @@ class TestGem < Gem::TestCase https://github.com/ruby/ruby/blob/trunk/test/rubygems/test_gem.rb#L299 gem 'c' Gem.finish_resolve - assert_equal %w( (... truncated) -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/