Update rubocop from 1.12 to 1.18 and min ruby from 2.4 to 2.5 (#8741)

Merge pull request 8741
This commit is contained in:
Andrew Davis 2021-07-23 01:58:40 +08:00 committed by GitHub
parent beca094841
commit 3f46f02108
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
11 changed files with 35 additions and 43 deletions

View File

@ -38,7 +38,7 @@ jobs:
fail-fast: false fail-fast: false
matrix: matrix:
ruby_version: ruby_version:
- 2.4 # Minimum required Ruby version in gemspec - 2.5 # Minimum required Ruby version in gemspec
steps: steps:
- uses: actions/checkout@v2 - uses: actions/checkout@v2
- name: Download released earth - name: Download released earth

View File

@ -13,7 +13,7 @@ Jekyll/NoPutsAllowed:
- rake/*.rake - rake/*.rake
AllCops: AllCops:
TargetRubyVersion: 2.4 TargetRubyVersion: 2.5
Include: Include:
- lib/**/*.rb - lib/**/*.rb
- test/**/*.rb - test/**/*.rb

View File

@ -23,7 +23,7 @@ group :test do
gem "nokogiri", "~> 1.7" gem "nokogiri", "~> 1.7"
gem "rspec" gem "rspec"
gem "rspec-mocks" gem "rspec-mocks"
gem "rubocop", "~> 1.12.0" gem "rubocop", "~> 1.18.3"
gem "rubocop-minitest" gem "rubocop-minitest"
gem "rubocop-performance" gem "rubocop-performance"
gem "rubocop-rake" gem "rubocop-rake"

View File

@ -1,3 +1,3 @@
min_version: 2.4.0 min_version: 2.5.0
current_version: 3.0.0 current_version: 3.0.0
current_version_output: ruby 3.0.0p0 (2020-12-25 revision 95aff21468) current_version_output: ruby 3.0.0p0 (2020-12-25 revision 95aff21468)

View File

@ -29,7 +29,7 @@ Gem::Specification.new do |s|
s.rdoc_options = ["--charset=UTF-8"] s.rdoc_options = ["--charset=UTF-8"]
s.extra_rdoc_files = %w(README.markdown LICENSE) s.extra_rdoc_files = %w(README.markdown LICENSE)
s.required_ruby_version = ">= 2.4.0" s.required_ruby_version = ">= 2.5.0"
s.required_rubygems_version = ">= 2.7.0" s.required_rubygems_version = ">= 2.7.0"
s.add_runtime_dependency("addressable", "~> 2.4") s.add_runtime_dependency("addressable", "~> 2.4")

View File

@ -160,7 +160,7 @@ module Jekyll
def strip_coderay_prefix(hash) def strip_coderay_prefix(hash)
hash.each_with_object({}) do |(key, val), hsh| hash.each_with_object({}) do |(key, val), hsh|
cleaned_key = key.to_s.gsub(%r!\Acoderay_!, "") cleaned_key = key.to_s.delete_prefix("coderay_")
if key != cleaned_key if key != cleaned_key
Jekyll::Deprecator.deprecation_message( Jekyll::Deprecator.deprecation_message(

View File

@ -22,13 +22,11 @@ module Jekyll
# #
def require_if_present(names) def require_if_present(names)
Array(names).each do |name| Array(names).each do |name|
begin require name
require name rescue LoadError
rescue LoadError Jekyll.logger.debug "Couldn't load #{name}. Skipping."
Jekyll.logger.debug "Couldn't load #{name}. Skipping." yield(name, version_constraint(name)) if block_given?
yield(name, version_constraint(name)) if block_given? false
false
end
end end
end end
@ -55,23 +53,21 @@ module Jekyll
# #
def require_with_graceful_fail(names) def require_with_graceful_fail(names)
Array(names).each do |name| Array(names).each do |name|
begin Jekyll.logger.debug "Requiring:", name.to_s
Jekyll.logger.debug "Requiring:", name.to_s require name
require name rescue LoadError => e
rescue LoadError => e Jekyll.logger.error "Dependency Error:", <<~MSG
Jekyll.logger.error "Dependency Error:", <<~MSG Yikes! It looks like you don't have #{name} or one of its dependencies installed.
Yikes! It looks like you don't have #{name} or one of its dependencies installed. In order to use Jekyll as currently configured, you'll need to install this gem.
In order to use Jekyll as currently configured, you'll need to install this gem.
If you've run Jekyll with `bundle exec`, ensure that you have included the #{name} If you've run Jekyll with `bundle exec`, ensure that you have included the #{name}
gem in your Gemfile as well. gem in your Gemfile as well.
The full error message from Ruby is: '#{e.message}' The full error message from Ruby is: '#{e.message}'
If you run into trouble, you can find helpful resources at https://jekyllrb.com/help/! If you run into trouble, you can find helpful resources at https://jekyllrb.com/help/!
MSG MSG
raise Jekyll::Errors::MissingDependencyException, name raise Jekyll::Errors::MissingDependencyException, name
end
end end
end end
end end

View File

@ -144,7 +144,7 @@ module Jekyll
# The path to the page source file, relative to the site source # The path to the page source file, relative to the site source
def relative_path def relative_path
@relative_path ||= PathManager.join(@dir, @name).sub(%r!\A/!, "") @relative_path ||= PathManager.join(@dir, @name).delete_prefix("/")
end end
# Obtain destination path. # Obtain destination path.

View File

@ -102,15 +102,13 @@ module Jekyll
# Returns String the converted content. # Returns String the converted content.
def convert(content) def convert(content)
converters.reduce(content) do |output, converter| converters.reduce(content) do |output, converter|
begin converter.convert output
converter.convert output rescue StandardError => e
rescue StandardError => e Jekyll.logger.error "Conversion error:",
Jekyll.logger.error "Conversion error:", "#{converter.class} encountered an error while "\
"#{converter.class} encountered an error while "\ "converting '#{document.relative_path}':"
"converting '#{document.relative_path}':" Jekyll.logger.error("", e.to_s)
Jekyll.logger.error("", e.to_s) raise e
raise e
end
end end
end end

View File

@ -260,7 +260,7 @@ module Jekyll
def resource_path(page, site) def resource_path(page, site)
path = page["path"] path = page["path"]
path = File.join(site.config["collections_dir"], path) if page["collection"] path = File.join(site.config["collections_dir"], path) if page["collection"]
path.sub(%r!/#excerpt\z!, "") path.delete_suffix("/#excerpt")
end end
end end
end end

View File

@ -130,11 +130,9 @@ class TestUtils < JekyllUnitTest
context "The \`Utils.slugify\` method" do context "The \`Utils.slugify\` method" do
should "return nil if passed nil" do should "return nil if passed nil" do
begin assert Utils.slugify(nil).nil?
assert Utils.slugify(nil).nil? rescue NoMethodError
rescue NoMethodError assert false, "Threw NoMethodError"
assert false, "Threw NoMethodError"
end
end end
should "replace whitespace with hyphens" do should "replace whitespace with hyphens" do