Bump RuboCop to `1.36.x` (#9125)

Merge pull request 9125
This commit is contained in:
Ashwin Maroli 2022-09-21 22:55:50 +05:30 committed by GitHub
parent d2c7c43c3f
commit 911e249d72
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
33 changed files with 167 additions and 114 deletions

View File

@ -27,6 +27,9 @@ AllCops:
Gemspec/DeprecatedAttributeAssignment: Gemspec/DeprecatedAttributeAssignment:
Enabled: true Enabled: true
Gemspec/RequireMFA:
Enabled: false
Layout/BeginEndAlignment: Layout/BeginEndAlignment:
Enabled: true Enabled: true
Layout/EmptyComment: Layout/EmptyComment:
@ -43,6 +46,12 @@ Layout/HashAlignment:
EnforcedHashRocketStyle: table EnforcedHashRocketStyle: table
Layout/IndentationWidth: Layout/IndentationWidth:
Severity: error Severity: error
Layout/LineContinuationLeadingSpace:
Enabled: true
Layout/LineContinuationSpacing:
Enabled: true
Layout/LineEndStringConcatenationIndentation:
Enabled: true
Layout/LineLength: Layout/LineLength:
Exclude: Exclude:
- !ruby/regexp /features\/.*.rb/ - !ruby/regexp /features\/.*.rb/
@ -66,12 +75,18 @@ Layout/SpaceInsideHashLiteralBraces:
Lint/AmbiguousAssignment: Lint/AmbiguousAssignment:
Enabled: true Enabled: true
Lint/AmbiguousOperatorPrecedence:
Enabled: true
Lint/AmbiguousRange:
Enabled: true
Lint/BinaryOperatorWithIdenticalOperands: Lint/BinaryOperatorWithIdenticalOperands:
Enabled: true Enabled: true
Lint/ConstantDefinitionInBlock: Lint/ConstantDefinitionInBlock:
Enabled: true Enabled: true
Exclude: Exclude:
- test/**/*.rb - test/**/*.rb
Lint/ConstantOverwrittenInRescue:
Enabled: true
Lint/DeprecatedConstants: Lint/DeprecatedConstants:
Enabled: true Enabled: true
Lint/DeprecatedOpenSSLConstant: Lint/DeprecatedOpenSSLConstant:
@ -123,6 +138,10 @@ Lint/RedundantDirGlobSort:
Enabled: true Enabled: true
Lint/RedundantSafeNavigation: Lint/RedundantSafeNavigation:
Enabled: true Enabled: true
Lint/RequireRangeParentheses:
Enabled: true
Lint/RequireRelativeSelfPath:
Enabled: true
Lint/SelfAssignment: Lint/SelfAssignment:
Enabled: true Enabled: true
Lint/StructNewOverride: Lint/StructNewOverride:
@ -187,6 +206,8 @@ Metrics/ParameterLists:
Metrics/PerceivedComplexity: Metrics/PerceivedComplexity:
Max: 13 Max: 13
Minitest/AssertEmptyLiteral:
Enabled: false
Minitest/AssertInDelta: Minitest/AssertInDelta:
Enabled: true Enabled: true
Minitest/AssertionInLifecycleHook: Minitest/AssertionInLifecycleHook:
@ -199,6 +220,8 @@ Minitest/AssertPathExists:
Enabled: true Enabled: true
Minitest/AssertSilent: Minitest/AssertSilent:
Enabled: true Enabled: true
Minitest/AssertWithExpectedArgument:
Enabled: true
Minitest/LiteralAsActualArgument: Minitest/LiteralAsActualArgument:
Enabled: true Enabled: true
Minitest/TestMethodName: Minitest/TestMethodName:
@ -211,10 +234,10 @@ Minitest/RefuteKindOf:
Enabled: true Enabled: true
Minitest/RefutePathExists: Minitest/RefutePathExists:
Enabled: true Enabled: true
Minitest/UnreachableAssertion:
Enabled: true
Minitest/UnspecifiedException: Minitest/UnspecifiedException:
Enabled: true Enabled: true
Minitest/AssertEmptyLiteral:
Enabled: false
Naming/FileName: Naming/FileName:
Enabled: false Enabled: false
@ -242,10 +265,16 @@ Performance/CollectionLiteralInLoop:
Enabled: true Enabled: true
Performance/ConstantRegexp: Performance/ConstantRegexp:
Enabled: true Enabled: true
Performance/MapCompact:
Enabled: true
Performance/MethodObjectAsBlock: Performance/MethodObjectAsBlock:
Enabled: true Enabled: true
Performance/RedundantEqualityComparisonBlock:
Enabled: false
Performance/RedundantSortBlock: Performance/RedundantSortBlock:
Enabled: true Enabled: true
Performance/RedundantSplitRegexpArgument:
Enabled: true
Performance/RedundantStringChars: Performance/RedundantStringChars:
Enabled: true Enabled: true
Performance/ReverseFirst: Performance/ReverseFirst:
@ -254,6 +283,8 @@ Performance/SortReverse:
Enabled: false Enabled: false
Performance/Squeeze: Performance/Squeeze:
Enabled: true Enabled: true
Performance/StringIdentifierArgument:
Enabled: true
Performance/StringInclude: Performance/StringInclude:
Enabled: true Enabled: true
Exclude: Exclude:
@ -261,6 +292,10 @@ Performance/StringInclude:
Performance/Sum: Performance/Sum:
Enabled: true Enabled: true
Security/CompoundHash:
Enabled: true
Security/IoMethods:
Enabled: true
Security/MarshalLoad: Security/MarshalLoad:
Exclude: Exclude:
- !ruby/regexp /test\/.*.rb$/ - !ruby/regexp /test\/.*.rb$/
@ -303,12 +338,20 @@ Style/Documentation:
Enabled: false Enabled: false
Style/DoubleNegation: Style/DoubleNegation:
Enabled: false Enabled: false
Style/EmptyHeredoc:
Enabled: true
Style/EndlessMethod: Style/EndlessMethod:
Enabled: true Enabled: true
Style/ExplicitBlockArgument: Style/ExplicitBlockArgument:
Enabled: false Enabled: false
Style/ExponentialNotation: Style/ExponentialNotation:
Enabled: true Enabled: true
Style/EnvHome:
Enabled: true
Style/FetchEnvVar:
Enabled: false
Style/FileRead:
Enabled: false
Style/FormatStringToken: Style/FormatStringToken:
Exclude: Exclude:
- lib/jekyll/utils/ansi.rb - lib/jekyll/utils/ansi.rb
@ -316,6 +359,8 @@ Style/FormatStringToken:
- lib/jekyll/profiler.rb - lib/jekyll/profiler.rb
Style/FrozenStringLiteralComment: Style/FrozenStringLiteralComment:
EnforcedStyle: always EnforcedStyle: always
Style/FileWrite:
Enabled: true
Style/GlobalStdStream: Style/GlobalStdStream:
Enabled: true Enabled: true
Style/GuardClause: Style/GuardClause:
@ -341,6 +386,12 @@ Style/IfWithBooleanLiteralBranches:
Enabled: true Enabled: true
Style/KeywordParametersOrder: Style/KeywordParametersOrder:
Enabled: true Enabled: true
Style/MagicCommentFormat:
Enabled: true
Style/MapCompactWithConditionalBlock:
Enabled: true
Style/MapToHash:
Enabled: true
Style/MixinUsage: Style/MixinUsage:
Exclude: Exclude:
- test/helper.rb - test/helper.rb
@ -350,10 +401,14 @@ Style/MultilineTernaryOperator:
Severity: error Severity: error
Style/NegatedIfElseCondition: Style/NegatedIfElseCondition:
Enabled: true Enabled: true
Style/NestedFileDirname:
Enabled: true
Style/NilLambda: Style/NilLambda:
Enabled: true Enabled: true
Style/OptionalBooleanParameter: Style/OptionalBooleanParameter:
Enabled: true Enabled: true
Exclude:
- lib/jekyll/log_adapter.rb
Style/PercentLiteralDelimiters: Style/PercentLiteralDelimiters:
PreferredDelimiters: PreferredDelimiters:
"%Q": "{}" "%Q": "{}"
@ -363,6 +418,8 @@ Style/PercentLiteralDelimiters:
"%s": () "%s": ()
"%w": () "%w": ()
"%x": () "%x": ()
Style/QuotedSymbols:
Enabled: true
Style/RedundantArgument: Style/RedundantArgument:
Enabled: true Enabled: true
Style/RedundantAssignment: Style/RedundantAssignment:
@ -371,12 +428,18 @@ Style/RedundantFetchBlock:
Enabled: false Enabled: false
Style/RedundantFileExtensionInRequire: Style/RedundantFileExtensionInRequire:
Enabled: true Enabled: true
Style/RedundantInitialize:
Enabled: true
Exclude:
- lib/jekyll/plugin.rb
Style/RedundantRegexpCharacterClass: Style/RedundantRegexpCharacterClass:
Enabled: true Enabled: true
Style/RedundantRegexpEscape: Style/RedundantRegexpEscape:
Enabled: true Enabled: true
Style/RedundantSelfAssignment: Style/RedundantSelfAssignment:
Enabled: true Enabled: true
Style/RedundantSelfAssignmentBranch:
Enabled: true
Style/RegexpLiteral: Style/RegexpLiteral:
EnforcedStyle: percent_r EnforcedStyle: percent_r
Style/RescueModifier: Style/RescueModifier:

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.32.0" gem "rubocop", "~> 1.36.0"
gem "rubocop-minitest" gem "rubocop-minitest"
gem "rubocop-performance" gem "rubocop-performance"
gem "rubocop-rake" gem "rubocop-rake"

View File

@ -30,8 +30,8 @@ module Jekyll
site = Jekyll::Site.new(options) site = Jekyll::Site.new(options)
if options.fetch("skip_initial_build", false) if options.fetch("skip_initial_build", false)
Jekyll.logger.warn "Build Warning:", "Skipping the initial build." \ Jekyll.logger.warn "Build Warning:",
" This may result in an out-of-date site." "Skipping the initial build. This may result in an out-of-date site."
else else
build(site, options) build(site, options)
end end

View File

@ -7,8 +7,7 @@ module Jekyll
def init_with_program(prog) def init_with_program(prog)
prog.command(:clean) do |c| prog.command(:clean) do |c|
c.syntax "clean [subcommand]" c.syntax "clean [subcommand]"
c.description "Clean the site " \ c.description "Clean the site (removes site output and metadata file) without building."
"(removes site output and metadata file) without building."
add_build_options(c) add_build_options(c)

View File

@ -59,8 +59,8 @@ module Jekyll
def deprecated_relative_permalinks(site) def deprecated_relative_permalinks(site)
if site.config["relative_permalinks"] if site.config["relative_permalinks"]
Jekyll::Deprecator.deprecation_message "Your site still uses relative permalinks," \ Jekyll::Deprecator.deprecation_message "Your site still uses relative permalinks, " \
" which was removed in Jekyll v3.0.0." "which was removed in Jekyll v3.0.0."
true true
end end
end end
@ -105,9 +105,9 @@ module Jekyll
next unless real_urls.uniq.size > 1 next unless real_urls.uniq.size > 1
urls_only_differ_by_case = true urls_only_differ_by_case = true
Jekyll.logger.warn "Warning:", "The following URLs only differ" \ Jekyll.logger.warn "Warning:", "The following URLs only differ by case. On a " \
" by case. On a case-insensitive file system one of the URLs" \ "case-insensitive file system one of the URLs will be " \
" will be overwritten by the other: #{real_urls.join(", ")}" "overwritten by the other: #{real_urls.join(", ")}"
end end
urls_only_differ_by_case urls_only_differ_by_case
end end
@ -148,8 +148,8 @@ module Jekyll
def url_exists?(url) def url_exists?(url)
return true unless url.nil? || url.empty? return true unless url.nil? || url.empty?
Jekyll.logger.warn "Warning:", "You didn't set an URL in the config file, "\ Jekyll.logger.warn "Warning:", "You didn't set an URL in the config file, you may " \
"you may encounter problems with some plugins." "encounter problems with some plugins."
false false
end end
@ -159,7 +159,7 @@ module Jekyll
# Addressable::URI#parse only raises a TypeError # Addressable::URI#parse only raises a TypeError
# https://github.com/sporkmonger/addressable/blob/0a0e96acb17225f9b1c9cab0bad332b448934c9a/lib/addressable/uri.rb#L103 # https://github.com/sporkmonger/addressable/blob/0a0e96acb17225f9b1c9cab0bad332b448934c9a/lib/addressable/uri.rb#L103
rescue TypeError rescue TypeError
Jekyll.logger.warn "Warning:", "The site URL does not seem to be valid, "\ Jekyll.logger.warn "Warning:", "The site URL does not seem to be valid, " \
"check the value of `url` in your config file." "check the value of `url` in your config file."
false false
end end
@ -167,7 +167,7 @@ module Jekyll
def url_absolute(url) def url_absolute(url)
return true if url.is_a?(String) && Addressable::URI.parse(url).absolute? return true if url.is_a?(String) && Addressable::URI.parse(url).absolute?
Jekyll.logger.warn "Warning:", "Your site URL does not seem to be absolute, "\ Jekyll.logger.warn "Warning:", "Your site URL does not seem to be absolute, " \
"check the value of `url` in your config file." "check the value of `url` in your config file."
false false
end end

View File

@ -28,8 +28,8 @@ module Jekyll
FileUtils.mkdir_p new_blog_path FileUtils.mkdir_p new_blog_path
if preserve_source_location?(new_blog_path, options) if preserve_source_location?(new_blog_path, options)
Jekyll.logger.error "Conflict:", "#{new_blog_path} exists and is not empty." Jekyll.logger.error "Conflict:", "#{new_blog_path} exists and is not empty."
Jekyll.logger.abort_with "", "Ensure #{new_blog_path} is empty or else " \ Jekyll.logger.abort_with "", "Ensure #{new_blog_path} is empty or else try again " \
"try again with `--force` to proceed and overwrite any files." "with `--force` to proceed and overwrite any files."
end end
if options["blank"] if options["blank"]
@ -108,13 +108,9 @@ module Jekyll
def create_site(new_blog_path) def create_site(new_blog_path)
create_sample_files new_blog_path create_sample_files new_blog_path
File.open(File.expand_path(initialized_post_name, new_blog_path), "w") do |f| File.write(File.expand_path(initialized_post_name, new_blog_path), scaffold_post_content)
f.write(scaffold_post_content)
end
File.open(File.expand_path("Gemfile", new_blog_path), "w") do |f| File.write(File.expand_path("Gemfile", new_blog_path), gemfile_contents)
f.write(gemfile_contents)
end
end end
def preserve_source_location?(path, options) def preserve_source_location?(path, options)

View File

@ -10,8 +10,7 @@ module Jekyll
prog.command(:"new-theme") do |c| prog.command(:"new-theme") do |c|
c.syntax "new-theme NAME" c.syntax "new-theme NAME"
c.description "Creates a new Jekyll theme scaffold" c.description "Creates a new Jekyll theme scaffold"
c.option "code_of_conduct", \ c.option "code_of_conduct", "-c", "--code-of-conduct",
"-c", "--code-of-conduct", \
"Include a Code of Conduct. (defaults to false)" "Include a Code of Conduct. (defaults to false)"
c.action do |args, opts| c.action do |args, opts|
@ -30,8 +29,8 @@ module Jekyll
Jekyll.logger.abort_with "Conflict:", "#{theme.path} already exists." if theme.path.exist? Jekyll.logger.abort_with "Conflict:", "#{theme.path} already exists." if theme.path.exist?
theme.create! theme.create!
Jekyll.logger.info "Your new Jekyll theme, #{theme.name.cyan}," \ Jekyll.logger.info "Your new Jekyll theme, #{theme.name.cyan}, " \
" is ready for you in #{theme.path.to_s.cyan}!" "is ready for you in #{theme.path.to_s.cyan}!"
Jekyll.logger.info "For help getting started, read #{theme.path}/README.md." Jekyll.logger.info "For help getting started, read #{theme.path}/README.md."
end end
end end

View File

@ -21,11 +21,11 @@ module Jekyll
"ssl_key" => ["--ssl-key [KEY]", "X.509 (SSL) Private Key."], "ssl_key" => ["--ssl-key [KEY]", "X.509 (SSL) Private Key."],
"port" => ["-P", "--port [PORT]", "Port to listen on"], "port" => ["-P", "--port [PORT]", "Port to listen on"],
"show_dir_listing" => ["--show-dir-listing", "show_dir_listing" => ["--show-dir-listing",
"Show a directory listing instead of loading" \ "Show a directory listing instead of loading " \
" your index file.",], "your index file.",],
"skip_initial_build" => ["skip_initial_build", "--skip-initial-build", "skip_initial_build" => ["skip_initial_build", "--skip-initial-build",
"Skips the initial site build which occurs before" \ "Skips the initial site build which occurs before " \
" the server is started.",], "the server is started.",],
"livereload" => ["-l", "--livereload", "livereload" => ["-l", "--livereload",
"Use LiveReload to automatically refresh browsers",], "Use LiveReload to automatically refresh browsers",],
"livereload_ignore" => ["--livereload-ignore ignore GLOB1[,GLOB2[,...]]", "livereload_ignore" => ["--livereload-ignore ignore GLOB1[,GLOB2[,...]]",
@ -113,8 +113,8 @@ module Jekyll
def validate_options(opts) def validate_options(opts)
if opts["livereload"] if opts["livereload"]
if opts["detach"] if opts["detach"]
Jekyll.logger.warn "Warning:", "--detach and --livereload are mutually exclusive." \ Jekyll.logger.warn "Warning:", "--detach and --livereload are mutually exclusive. " \
" Choosing --livereload" "Choosing --livereload"
opts["detach"] = false opts["detach"] = false
end end
if opts["ssl_cert"] || opts["ssl_key"] if opts["ssl_cert"] || opts["ssl_key"]
@ -132,9 +132,9 @@ module Jekyll
livereload_max_delay livereload_max_delay
livereload_ignore livereload_ignore
livereload_port).any? { |o| opts[o] } livereload_port).any? { |o| opts[o] }
Jekyll.logger.abort_with "--livereload-min-delay, "\ Jekyll.logger.abort_with "--livereload-min-delay, --livereload-max-delay, " \
"--livereload-max-delay, --livereload-ignore, and "\ "--livereload-ignore, and --livereload-port require " \
"--livereload-port require the --livereload option." "the --livereload option."
end end
end end
@ -174,7 +174,8 @@ module Jekyll
# Do a base pre-setup of WEBRick so that everything is in place # Do a base pre-setup of WEBRick so that everything is in place
# when we get ready to party, checking for an setting up an error page # when we get ready to party, checking for an setting up an error page
# and making sure our destination exists. # and making sure our destination exists.
#
# rubocop:disable Security/IoMethods
def setup(destination) def setup(destination)
require_relative "serve/servlet" require_relative "serve/servlet"
@ -188,6 +189,7 @@ module Jekyll
end end
end end
end end
# rubocop:enable Security/IoMethods
def webrick_opts(opts) def webrick_opts(opts)
opts = { opts = {
@ -263,8 +265,7 @@ module Jekyll
return system "xdg-open", address if Utils::Platforms.linux? return system "xdg-open", address if Utils::Platforms.linux?
return system "open", address if Utils::Platforms.osx? return system "open", address if Utils::Platforms.osx?
Jekyll.logger.error "Refusing to launch browser; " \ Jekyll.logger.error "Refusing to launch browser. Platform launcher unknown."
"Platform launcher unknown."
end end
# Keep in our area with a thread or detach the server as requested # Keep in our area with a thread or detach the server as requested
@ -277,9 +278,8 @@ module Jekyll
end end
Process.detach(pid) Process.detach(pid)
Jekyll.logger.info "Server detached with pid '#{pid}'.", \ Jekyll.logger.info "Server detached with pid '#{pid}'.",
"Run `pkill -f jekyll' or `kill -9 #{pid}'" \ "Run `pkill -f jekyll' or `kill -9 #{pid}' to stop the server."
" to stop the server."
else else
t = Thread.new { server.start } t = Thread.new { server.start }
trap("INT") { server.shutdown } trap("INT") { server.shutdown }

View File

@ -304,8 +304,8 @@ module Jekyll
return if config["plugins"].is_a?(Array) return if config["plugins"].is_a?(Array)
Jekyll.logger.error "'plugins' should be set as an array of gem-names, but was: " \ Jekyll.logger.error "'plugins' should be set as an array of gem-names, but was: " \
"#{config["plugins"].inspect}. Use 'plugins_dir' instead to set the directory " \ "#{config["plugins"].inspect}. Use 'plugins_dir' instead to set " \
"for your non-gemified Ruby plugins." "the directory for your non-gemified Ruby plugins."
raise Jekyll::Errors::InvalidConfigurationError, raise Jekyll::Errors::InvalidConfigurationError,
"'plugins' should be set as an array, but was: #{config["plugins"].inspect}." "'plugins' should be set as an array, but was: #{config["plugins"].inspect}."
end end

View File

@ -1,4 +1,4 @@
# Frozen-string-literal: true # frozen_string_literal: true
module Kramdown module Kramdown
# A Kramdown::Document subclass meant to optimize memory usage from initializing # A Kramdown::Document subclass meant to optimize memory usage from initializing

View File

@ -190,8 +190,8 @@ module Jekyll
def print_build_warning def print_build_warning
Jekyll.logger.warn "Warning:", "Excerpt modified in #{doc.relative_path}!" Jekyll.logger.warn "Warning:", "Excerpt modified in #{doc.relative_path}!"
Jekyll.logger.warn "", "Found a Liquid block containing the excerpt separator" \ Jekyll.logger.warn "", "Found a Liquid block containing the excerpt separator " \
" #{doc.excerpt_separator.inspect}. " "#{doc.excerpt_separator.inspect}."
Jekyll.logger.warn "", "The block has been modified with the appropriate closing tag." Jekyll.logger.warn "", "The block has been modified with the appropriate closing tag."
Jekyll.logger.warn "", "Feel free to define a custom excerpt or excerpt_separator in the" Jekyll.logger.warn "", "Feel free to define a custom excerpt or excerpt_separator in the"
Jekyll.logger.warn "", "document's Front Matter if the generated excerpt is unsatisfactory." Jekyll.logger.warn "", "document's Front Matter if the generated excerpt is unsatisfactory."

View File

@ -78,8 +78,8 @@ module Jekyll
} }
unless @registry[owner][event] unless @registry[owner][event]
raise NotAvailable, "Invalid hook. #{owner} supports only the " \ raise NotAvailable, "Invalid hook. #{owner} supports only the following hooks " \
"following hooks #{@registry[owner].keys.inspect}" "#{@registry[owner].keys.inspect}"
end end
raise Uncallable, "Hooks must respond to :call" unless block.respond_to? :call raise Uncallable, "Hooks must respond to :call" unless block.respond_to? :call

View File

@ -113,9 +113,10 @@ module Jekyll
pagination_included = (site.config["plugins"] || []).include?("jekyll-paginate") || pagination_included = (site.config["plugins"] || []).include?("jekyll-paginate") ||
defined?(Jekyll::Paginate) defined?(Jekyll::Paginate)
if site.config["paginate"] && !pagination_included if site.config["paginate"] && !pagination_included
Jekyll::Deprecator.deprecation_message "You appear to have pagination " \ Jekyll::Deprecator.deprecation_message <<~MSG
"turned on, but you haven't included the `jekyll-paginate` gem. " \ You appear to have pagination turned on, but you haven't included the `jekyll-paginate`
"Ensure you have `plugins: [jekyll-paginate]` in your configuration file." gem. Ensure you have `plugins: [jekyll-paginate]` in your configuration file.
MSG
end end
end end
end end

View File

@ -105,7 +105,7 @@ module Jekyll
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

View File

@ -328,11 +328,11 @@ module Jekyll
# Returns # Returns
def relative_permalinks_are_deprecated def relative_permalinks_are_deprecated
if config["relative_permalinks"] if config["relative_permalinks"]
Jekyll.logger.abort_with "Since v3.0, permalinks for pages" \ Jekyll.logger.abort_with "Since v3.0, permalinks for pages " \
" in subfolders must be relative to the" \ "in subfolders must be relative to the " \
" site source directory, not the parent" \ "site source directory, not the parent " \
" directory. Check https://jekyllrb.com/docs/upgrading/"\ "directory. Check https://jekyllrb.com/docs/upgrading/ " \
" for more info." "for more info."
end end
end end
@ -536,8 +536,8 @@ module Jekyll
if config["theme"].is_a?(String) if config["theme"].is_a?(String)
Jekyll::Theme.new(config["theme"]) Jekyll::Theme.new(config["theme"])
else else
Jekyll.logger.warn "Theme:", "value of 'theme' in config should be " \ Jekyll.logger.warn "Theme:", "value of 'theme' in config should be String to use " \
"String to use gem-based themes, but got #{config["theme"].class}" "gem-based themes, but got #{config["theme"].class}"
nil nil
end end
end end

View File

@ -104,7 +104,7 @@ module Jekyll
"class=\"language-#{@lang.to_s.tr("+", "-")}\"", "class=\"language-#{@lang.to_s.tr("+", "-")}\"",
"data-lang=\"#{@lang}\"", "data-lang=\"#{@lang}\"",
].join(" ") ].join(" ")
"<figure class=\"highlight\"><pre><code #{code_attributes}>"\ "<figure class=\"highlight\"><pre><code #{code_attributes}>" \
"#{code.chomp}</code></pre></figure>" "#{code.chomp}</code></pre></figure>"
end end
end end

View File

@ -179,8 +179,8 @@ module Jekyll
private private
def could_not_locate_message(file, includes_dirs, safe) def could_not_locate_message(file, includes_dirs, safe)
message = "Could not locate the included file '#{file}' in any of "\ message = "Could not locate the included file '#{file}' in any of #{includes_dirs}. " \
"#{includes_dirs}. Ensure it exists in one of those directories and" "Ensure it exists in one of those directories and"
message + if safe message + if safe
" is not a symlink as those are not allowed in safe mode." " is not a symlink as those are not allowed in safe mode."
else else

View File

@ -86,11 +86,11 @@ module Jekyll
site.posts.docs.each do |document| site.posts.docs.each do |document|
next unless @post.deprecated_equality document next unless @post.deprecated_equality document
Jekyll::Deprecator.deprecation_message "A call to "\ Jekyll::Deprecator.deprecation_message(
"'{% post_url #{@post.name} %}' did not match " \ "A call to '{% post_url #{@post.name} %}' did not match a post using the new " \
"a post using the new matching method of checking name " \ "matching method of checking name (path-date-slug) equality. Please make sure " \
"(path-date-slug) equality. Please make sure that you " \ "that you change this tag to match the post's name exactly."
"change this tag to match the post's name exactly." )
return relative_url(document) return relative_url(document)
end end

View File

@ -18,8 +18,8 @@ module Jekyll
# Otherwise, Jekyll.sanitized path with prepend the unresolved root # Otherwise, Jekyll.sanitized path with prepend the unresolved root
@root ||= File.realpath(gemspec.full_gem_path) @root ||= File.realpath(gemspec.full_gem_path)
rescue Errno::ENOENT, Errno::EACCES, Errno::ELOOP rescue Errno::ENOENT, Errno::EACCES, Errno::ELOOP
raise "Path #{gemspec.full_gem_path} does not exist, is not accessible "\ raise "Path #{gemspec.full_gem_path} does not exist, is not accessible or includes " \
"or includes a symbolic link loop" "a symbolic link loop"
end end
# The name of theme directory # The name of theme directory

View File

@ -100,7 +100,7 @@ module Jekyll
winner = pool.find { |key| @placeholders.key?(key) } winner = pool.find { |key| @placeholders.key?(key) }
if winner.nil? if winner.nil?
raise NoMethodError, raise NoMethodError,
"The URL template doesn't have #{pool.join(" or ")} keys. "\ "The URL template doesn't have #{pool.join(" or ")} keys. " \
"Check your permalink template!" "Check your permalink template!"
end end

View File

@ -1,4 +1,4 @@
# Frozen-string-literal: true # frozen_string_literal: true
module Jekyll module Jekyll
module Utils module Utils

View File

@ -105,8 +105,7 @@ class JekyllUnitTest < Minitest::Test
end end
def mocks_expect(*args) def mocks_expect(*args)
RSpec::Mocks::ExampleMethods::ExpectHost.instance_method(:expect)\ RSpec::Mocks::ExampleMethods::ExpectHost.instance_method(:expect).bind(self).call(*args)
.bind(self).call(*args)
end end
def before_setup def before_setup
@ -166,7 +165,7 @@ class JekyllUnitTest < Minitest::Test
def directory_with_contents(path) def directory_with_contents(path)
FileUtils.rm_rf(path) FileUtils.rm_rf(path)
FileUtils.mkdir(path) FileUtils.mkdir(path)
File.open("#{path}/index.html", "w") { |f| f.write("I was previously generated.") } File.write("#{path}/index.html", "I was previously generated.")
end end
def with_env(key, value) def with_env(key, value)

View File

@ -75,9 +75,7 @@ class TestCommandsServe < JekyllUnitTest
</html> </html>
HTML HTML
File.open(File.join(@destination, "hello.html"), "w") do |f| File.write(File.join(@destination, "hello.html"), simple_page)
f.write(simple_page)
end
allow(Jekyll::Site).to receive(:new).and_return(site) allow(Jekyll::Site).to receive(:new).and_return(site)
end end

View File

@ -22,6 +22,7 @@ class TestDoctorCommand < JekyllUnitTest
assert_equal "", output assert_equal "", output
end end
# rubocop:disable Layout/LineLength
should "return warning for pages only differing by case" do should "return warning for pages only differing by case" do
@site = Site.new(Jekyll.configuration( @site = Site.new(Jekyll.configuration(
"source" => File.join(source_dir, "/_urls_differ_by_case_invalid"), "source" => File.join(source_dir, "/_urls_differ_by_case_invalid"),
@ -32,9 +33,10 @@ class TestDoctorCommand < JekyllUnitTest
ret = Jekyll::Commands::Doctor.urls_only_differ_by_case(@site) ret = Jekyll::Commands::Doctor.urls_only_differ_by_case(@site)
assert ret assert ret
end end
assert_includes output, "Warning: The following URLs only differ by case. "\ assert_includes output, "Warning: The following URLs only differ by case. On a case-" \
"On a case-insensitive file system one of the URLs will be overwritten by the "\ "insensitive file system one of the URLs will be overwritten by the " \
"other: #{dest_dir}/about/index.html, #{dest_dir}/About/index.html" "other: #{dest_dir}/about/index.html, #{dest_dir}/About/index.html"
end end
# rubocop:enable Layout/LineLength
end end
end end

View File

@ -111,8 +111,7 @@ class TestExcerpt < JekyllUnitTest
context "#content" do context "#content" do
context "before render" do context "before render" do
should "be the first paragraph of the page" do should "be the first paragraph of the page" do
expected = "First paragraph with [link ref][link].\n\n[link]: "\ expected = "First paragraph with [link ref][link].\n\n[link]: https://jekyllrb.com/"
"https://jekyllrb.com/"
assert_equal expected, @excerpt.content assert_equal expected, @excerpt.content
end end
@ -129,7 +128,7 @@ class TestExcerpt < JekyllUnitTest
end end
should "be the first paragraph of the page" do should "be the first paragraph of the page" do
expected = "<p>First paragraph with <a href=\"https://jekyllrb.com/\">link "\ expected = "<p>First paragraph with <a href=\"https://jekyllrb.com/\">link " \
"ref</a>.</p>\n\n" "ref</a>.</p>\n\n"
assert_equal expected, @extracted_excerpt.output assert_equal expected, @extracted_excerpt.output
end end
@ -146,7 +145,7 @@ class TestExcerpt < JekyllUnitTest
end end
should "contain all refs at the bottom of the page" do should "contain all refs at the bottom of the page" do
(0..3).each do |i| 4.times do |i|
assert_match "[link_#{i}]: www.example.com/#{i}", @excerpt.content assert_match "[link_#{i}]: www.example.com/#{i}", @excerpt.content
end end
end end
@ -159,7 +158,7 @@ class TestExcerpt < JekyllUnitTest
@rendered_post = @post.dup @rendered_post = @post.dup
do_render(@rendered_post) do_render(@rendered_post)
output = @rendered_post.data["excerpt"].output output = @rendered_post.data["excerpt"].output
(0..3).each do |i| 4.times do |i|
assert_includes output, "<a href=\"www.example.com/#{i}\">" assert_includes output, "<a href=\"www.example.com/#{i}\">"
end end
end end

View File

@ -164,8 +164,8 @@ class TestPageWithoutAFile < JekyllUnitTest
refute_path_exists(dest_dir("virtual-about", "index.html")) refute_path_exists(dest_dir("virtual-about", "index.html"))
end end
should "be processed and written to destination when passed as "\ should "be processed and written to destination when passed as an entry in " \
"an entry in 'site.pages' array" do "'site.pages' array" do
@page.content = "{{ site.title }}" @page.content = "{{ site.title }}"
@page.data["permalink"] = "/virtual-about/" @page.data["permalink"] = "/virtual-about/"

View File

@ -174,9 +174,7 @@ class TestRegenerator < JekyllUnitTest
metadata_file = source_dir(".jekyll-metadata") metadata_file = source_dir(".jekyll-metadata")
@regenerator = Regenerator.new(@site) @regenerator = Regenerator.new(@site)
File.open(metadata_file, "w") do |f| File.write(metadata_file, @regenerator.metadata.to_yaml)
f.write(@regenerator.metadata.to_yaml)
end
@regenerator = Regenerator.new(@site) @regenerator = Regenerator.new(@site)
assert_equal File.mtime(@path), @regenerator.metadata[@path]["mtime"] assert_equal File.mtime(@path), @regenerator.metadata[@path]["mtime"]

View File

@ -621,8 +621,8 @@ class TestSite < JekyllUnitTest
site = fixture_site("theme" => {}) site = fixture_site("theme" => {})
assert_nil site.theme assert_nil site.theme
end end
expected_msg = "Theme: value of 'theme' in config should be String " \ expected_msg = "Theme: value of 'theme' in config should be String to use " \
"to use gem-based themes, but got Hash\n" "gem-based themes, but got Hash\n"
assert_includes output, expected_msg assert_includes output, expected_msg
end end

View File

@ -450,10 +450,10 @@ class TestTags < JekyllUnitTest
end end
should "throw a deprecation warning" do should "throw a deprecation warning" do
deprecation_warning = " Deprecation: A call to "\ deprecation_warning = " Deprecation: A call to '{% post_url 2008-11-21-nested %}' " \
"'{% post_url 2008-11-21-nested %}' did not match a post using the new matching "\ "did not match a post using the new matching method of checking " \
"method of checking name (path-date-slug) equality. Please make sure that you "\ "name (path-date-slug) equality. Please make sure that you change " \
"change this tag to match the post's name exactly." "this tag to match the post's name exactly."
assert_includes Jekyll.logger.messages, deprecation_warning assert_includes Jekyll.logger.messages, deprecation_warning
end end
end end
@ -693,7 +693,7 @@ class TestTags < JekyllUnitTest
context "include tag with parameters" do context "include tag with parameters" do
context "with symlink'd include" do context "with symlink'd include" do
should "not allow symlink includes" do should "not allow symlink includes" do
File.open("tmp/pages-test", "w") { |file| file.write("SYMLINK TEST") } File.write("tmp/pages-test", "SYMLINK TEST")
assert_raises IOError do assert_raises IOError do
content = <<~CONTENT content = <<~CONTENT
--- ---
@ -1142,7 +1142,7 @@ class TestTags < JekyllUnitTest
context "with symlink'd include" do context "with symlink'd include" do
should "not allow symlink includes" do should "not allow symlink includes" do
File.open("tmp/pages-test", "w") { |file| file.write("SYMLINK TEST") } File.write("tmp/pages-test", "SYMLINK TEST")
assert_raises IOError do assert_raises IOError do
content = <<~CONTENT content = <<~CONTENT
--- ---
@ -1181,7 +1181,7 @@ class TestTags < JekyllUnitTest
"safe" => true) "safe" => true)
end end
assert_match( assert_match(
"Ensure it exists in one of those directories and is not a symlink "\ "Ensure it exists in one of those directories and is not a symlink " \
"as those are not allowed in safe mode.", "as those are not allowed in safe mode.",
ex.message ex.message
) )

View File

@ -14,15 +14,14 @@ class TestThemeAssetsReader < JekyllUnitTest
def assert_file_with_relative_path(haystack, relative_path) def assert_file_with_relative_path(haystack, relative_path)
assert haystack.any? { |f| assert haystack.any? { |f|
f.relative_path == relative_path f.relative_path == relative_path
}, "Site should read in the #{relative_path} file, " \ }, "Site should read in the #{relative_path} file, but it was not found in #{haystack.inspect}"
"but it was not found in #{haystack.inspect}"
end end
def refute_file_with_relative_path(haystack, relative_path) def refute_file_with_relative_path(haystack, relative_path)
refute haystack.any? { |f| refute haystack.any? { |f|
f.relative_path == relative_path f.relative_path == relative_path
}, "Site should not have read in the #{relative_path} file, " \ }, "Site should not have read in the #{relative_path} file, but it was found in " \
"but it was found in #{haystack.inspect}" "#{haystack.inspect}"
end end
context "with a valid theme" do context "with a valid theme" do
@ -82,7 +81,7 @@ class TestThemeAssetsReader < JekyllUnitTest
begin begin
tmp_dir = Dir.mktmpdir("jekyll-theme-test") tmp_dir = Dir.mktmpdir("jekyll-theme-test")
File.open(File.join(tmp_dir, "test.txt"), "wb") { |f| f.write "content" } File.binwrite(File.join(tmp_dir, "test.txt"), "content")
theme_dir = File.join(__dir__, "fixtures", "test-theme-symlink") theme_dir = File.join(__dir__, "fixtures", "test-theme-symlink")
File.symlink(tmp_dir, File.join(theme_dir, "assets")) File.symlink(tmp_dir, File.join(theme_dir, "assets"))