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
matrix:
ruby_version:
- 2.4 # Minimum required Ruby version in gemspec
- 2.5 # Minimum required Ruby version in gemspec
steps:
- uses: actions/checkout@v2
- name: Download released earth

View File

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

View File

@ -23,7 +23,7 @@ group :test do
gem "nokogiri", "~> 1.7"
gem "rspec"
gem "rspec-mocks"
gem "rubocop", "~> 1.12.0"
gem "rubocop", "~> 1.18.3"
gem "rubocop-minitest"
gem "rubocop-performance"
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_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.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.add_runtime_dependency("addressable", "~> 2.4")

View File

@ -160,7 +160,7 @@ module Jekyll
def strip_coderay_prefix(hash)
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
Jekyll::Deprecator.deprecation_message(

View File

@ -22,13 +22,11 @@ module Jekyll
#
def require_if_present(names)
Array(names).each do |name|
begin
require name
rescue LoadError
Jekyll.logger.debug "Couldn't load #{name}. Skipping."
yield(name, version_constraint(name)) if block_given?
false
end
require name
rescue LoadError
Jekyll.logger.debug "Couldn't load #{name}. Skipping."
yield(name, version_constraint(name)) if block_given?
false
end
end
@ -55,23 +53,21 @@ module Jekyll
#
def require_with_graceful_fail(names)
Array(names).each do |name|
begin
Jekyll.logger.debug "Requiring:", name.to_s
require name
rescue LoadError => e
Jekyll.logger.error "Dependency Error:", <<~MSG
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.
Jekyll.logger.debug "Requiring:", name.to_s
require name
rescue LoadError => e
Jekyll.logger.error "Dependency Error:", <<~MSG
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.
If you've run Jekyll with `bundle exec`, ensure that you have included the #{name}
gem in your Gemfile as well.
If you've run Jekyll with `bundle exec`, ensure that you have included the #{name}
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/!
MSG
raise Jekyll::Errors::MissingDependencyException, name
end
If you run into trouble, you can find helpful resources at https://jekyllrb.com/help/!
MSG
raise Jekyll::Errors::MissingDependencyException, name
end
end
end

View File

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

View File

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

View File

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

View File

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