Bump RuboCop to v0.85.x (#8223)

Merge pull request 8223
This commit is contained in:
Ashwin Maroli 2020-06-01 23:37:43 +05:30 committed by GitHub
parent 4046ca2322
commit 751b8f9c3c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
13 changed files with 30 additions and 24 deletions

View File

@ -56,6 +56,8 @@ Lint/NestedPercentLiteral:
- test/test_site.rb - test/test_site.rb
Lint/DeprecatedOpenSSLConstant: Lint/DeprecatedOpenSSLConstant:
Enabled: true Enabled: true
Lint/MixedRegexpCaptureTypes:
Enabled: false
Lint/RaiseException: Lint/RaiseException:
Enabled: true Enabled: true
Lint/StructNewOverride: Lint/StructNewOverride:
@ -169,6 +171,10 @@ Style/PercentLiteralDelimiters:
"%w": "()" "%w": "()"
"%W": "()" "%W": "()"
"%x": "()" "%x": "()"
Style/RedundantRegexpCharacterClass:
Enabled: true
Style/RedundantRegexpEscape:
Enabled: true
Style/RegexpLiteral: Style/RegexpLiteral:
EnforcedStyle: percent_r EnforcedStyle: percent_r
Style/RescueModifier: Style/RescueModifier:

View File

@ -28,7 +28,7 @@ group :test do
gem "nokogiri", "~> 1.7" gem "nokogiri", "~> 1.7"
gem "rspec" gem "rspec"
gem "rspec-mocks" gem "rspec-mocks"
gem "rubocop", "~> 0.84.0" gem "rubocop", "~> 0.85.0"
gem "rubocop-performance" gem "rubocop-performance"
gem "test-dependency-theme", :path => File.expand_path("test/fixtures/test-dependency-theme", __dir__) gem "test-dependency-theme", :path => File.expand_path("test/fixtures/test-dependency-theme", __dir__)
gem "test-theme", :path => File.expand_path("test/fixtures/test-theme", __dir__) gem "test-theme", :path => File.expand_path("test/fixtures/test-theme", __dir__)

View File

@ -3,7 +3,7 @@
module Jekyll module Jekyll
# Handles the cleanup of a site's destination before it is built. # Handles the cleanup of a site's destination before it is built.
class Cleaner class Cleaner
HIDDEN_FILE_REGEX = %r!\/\.{1,2}$!.freeze HIDDEN_FILE_REGEX = %r!/\.{1,2}$!.freeze
attr_reader :site attr_reader :site
def initialize(site) def initialize(site)
@ -105,7 +105,7 @@ module Jekyll
# #
# Returns the regular expression # Returns the regular expression
def keep_file_regex def keep_file_regex
%r!\A#{Regexp.quote(site.dest)}\/(#{Regexp.union(site.keep_files).source})! %r!\A#{Regexp.quote(site.dest)}/(#{Regexp.union(site.keep_files).source})!
end end
end end
end end

View File

@ -166,7 +166,7 @@ module Jekyll
# #
# Returns a sanitized version of the label. # Returns a sanitized version of the label.
def sanitize_label(label) def sanitize_label(label)
label.gsub(%r![^a-z0-9_\-\.]!i, "") label.gsub(%r![^a-z0-9_\-.]!i, "")
end end
# Produce a representation of this Collection for use in Liquid. # Produce a representation of this Collection for use in Liquid.

View File

@ -178,7 +178,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 ||= File.join(*[@dir, @name].map(&:to_s).reject(&:empty?)).sub(%r!\A\/!, "") @relative_path ||= File.join(*[@dir, @name].map(&:to_s).reject(&:empty?)).sub(%r!\A/!, "")
end end
# Obtain destination path. # Obtain destination path.

View File

@ -5,15 +5,15 @@ module Jekyll
class IncludeTag < Liquid::Tag class IncludeTag < Liquid::Tag
VALID_SYNTAX = %r! VALID_SYNTAX = %r!
([\w-]+)\s*=\s* ([\w-]+)\s*=\s*
(?:"([^"\\]*(?:\\.[^"\\]*)*)"|'([^'\\]*(?:\\.[^'\\]*)*)'|([\w\.-]+)) (?:"([^"\\]*(?:\\.[^"\\]*)*)"|'([^'\\]*(?:\\.[^'\\]*)*)'|([\w.-]+))
!x.freeze !x.freeze
VARIABLE_SYNTAX = %r! VARIABLE_SYNTAX = %r!
(?<variable>[^{]*(\{\{\s*[\w\-\.]+\s*(\|.*)?\}\}[^\s{}]*)+) (?<variable>[^{]*(\{\{\s*[\w\-.]+\s*(\|.*)?\}\}[^\s{}]*)+)
(?<params>.*) (?<params>.*)
!mx.freeze !mx.freeze
FULL_VALID_SYNTAX = %r!\A\s*(?:#{VALID_SYNTAX}(?=\s|\z)\s*)*\z!.freeze FULL_VALID_SYNTAX = %r!\A\s*(?:#{VALID_SYNTAX}(?=\s|\z)\s*)*\z!.freeze
VALID_FILENAME_CHARS = %r!^[\w/\.-]+$!.freeze VALID_FILENAME_CHARS = %r!^[\w/.-]+$!.freeze
INVALID_SEQUENCES = %r![./]{2,}!.freeze INVALID_SEQUENCES = %r![./]{2,}!.freeze
def initialize(tag_name, markup, tokens) def initialize(tag_name, markup, tokens)

View File

@ -215,7 +215,7 @@ module Jekyll
slug = replace_character_sequence_with_hyphen(string, :mode => mode) slug = replace_character_sequence_with_hyphen(string, :mode => mode)
# Remove leading/trailing hyphen # Remove leading/trailing hyphen
slug.gsub!(%r!^\-|\-$!i, "") slug.gsub!(%r!^-|-$!i, "")
slug.downcase! unless cased slug.downcase! unless cased
Jekyll.logger.warn("Warning:", "Empty `slug` generated for '#{string}'.") if slug.empty? Jekyll.logger.warn("Warning:", "Empty `slug` generated for '#{string}'.") if slug.empty?

View File

@ -83,7 +83,7 @@ module DirectoryHelpers
def temp_dir(*subdirs) def temp_dir(*subdirs)
if Utils::Platforms.windows? if Utils::Platforms.windows?
drive = Dir.pwd.sub(%r!^([^\/]+).*!, '\1') drive = Dir.pwd.sub(%r!^([^/]+).*!, '\1')
temp_root = File.join(drive, "tmp") temp_root = File.join(drive, "tmp")
else else
temp_root = "/tmp" temp_root = "/tmp"

View File

@ -47,7 +47,7 @@ class TestConvertible < JekyllUnitTest
out = capture_stderr do out = capture_stderr do
@convertible.read_yaml(@base, "exploit_front_matter.erb") @convertible.read_yaml(@base, "exploit_front_matter.erb")
end end
refute_match(%r!undefined class\/module DoesNotExist!, out) refute_match(%r!undefined class/module DoesNotExist!, out)
end end
should "not parse if there is encoding error in file" do should "not parse if there is encoding error in file" do

View File

@ -97,7 +97,7 @@ class TestFrontMatterDefaults < JekyllUnitTest
) )
@site.process @site.process
@affected = @site.posts.docs.find { |page| page.relative_path =~ %r!win\/! } @affected = @site.posts.docs.find { |page| page.relative_path =~ %r!win/! }
@not_affected = @site.pages.find { |page| page.relative_path == "about.html" } @not_affected = @site.pages.find { |page| page.relative_path == "about.html" }
end end

View File

@ -117,7 +117,7 @@ class TestKramdown < JekyllUnitTest
should "convert" do should "convert" do
converter = fixture_converter(@config) converter = fixture_converter(@config)
assert_match( assert_match(
%r!<p>(&#8220;|“)Pit(&#8217;|)hy(&#8221;|”)<\/p>!, %r!<p>(&#8220;|“)Pit(&#8217;|)hy(&#8221;|”)</p>!,
converter.convert(%("Pit'hy")).strip converter.convert(%("Pit'hy")).strip
) )
end end
@ -130,7 +130,7 @@ class TestKramdown < JekyllUnitTest
}, },
} }
converter = fixture_converter(Utils.deep_merge_hashes(@config, override)) converter = fixture_converter(Utils.deep_merge_hashes(@config, override))
assert_match %r!<p>(&#171;|«)Pit(&#8250;|)hy(&#187;|»)<\/p>!, \ assert_match %r!<p>(&#171;|«)Pit(&#8250;|)hy(&#187;|»)</p>!, \
converter.convert(%("Pit'hy")).strip converter.convert(%("Pit'hy")).strip
end end
end end

View File

@ -360,7 +360,7 @@ class TestTags < JekyllUnitTest
end end
should "not cause an error" do should "not cause an error" do
refute_match(%r!markdown\-html\-error!, @result) refute_match(%r!markdown-html-error!, @result)
end end
should "have the URL to the 'complex' post from 2008-11-21" do should "have the URL to the 'complex' post from 2008-11-21" do
@ -385,7 +385,7 @@ class TestTags < JekyllUnitTest
end end
should "not cause an error" do should "not cause an error" do
refute_match(%r!markdown\-html\-error!, @result) refute_match(%r!markdown-html-error!, @result)
end end
should "have the URL to the 'special-chars' post from 2016-11-26" do should "have the URL to the 'special-chars' post from 2016-11-26" do
@ -413,7 +413,7 @@ class TestTags < JekyllUnitTest
end end
should "not cause an error" do should "not cause an error" do
refute_match(%r!markdown\-html\-error!, @result) refute_match(%r!markdown-html-error!, @result)
end end
should "have the URL to the 'complex' post from 2008-11-21" do should "have the URL to the 'complex' post from 2008-11-21" do
@ -444,7 +444,7 @@ class TestTags < JekyllUnitTest
end end
should "not cause an error" do should "not cause an error" do
refute_match(%r!markdown\-html\-error!, @result) refute_match(%r!markdown-html-error!, @result)
end end
should "have the url to the 'nested' post from 2008-11-21" do should "have the url to the 'nested' post from 2008-11-21" do
@ -516,7 +516,7 @@ class TestTags < JekyllUnitTest
end end
should "not cause an error" do should "not cause an error" do
refute_match(%r!markdown\-html\-error!, @result) refute_match(%r!markdown-html-error!, @result)
end end
should "have the URL to the 'contacts' item" do should "have the URL to the 'contacts' item" do
@ -554,7 +554,7 @@ class TestTags < JekyllUnitTest
end end
should "not cause an error" do should "not cause an error" do
refute_match(%r!markdown\-html\-error!, @result) refute_match(%r!markdown-html-error!, @result)
end end
should "have the URL to the 'contacts' item" do should "have the URL to the 'contacts' item" do
@ -587,7 +587,7 @@ class TestTags < JekyllUnitTest
end end
should "not cause an error" do should "not cause an error" do
refute_match(%r!markdown\-html\-error!, @result) refute_match(%r!markdown-html-error!, @result)
end end
should "have the URL to the 'yaml_with_dots' item" do should "have the URL to the 'yaml_with_dots' item" do
@ -613,7 +613,7 @@ class TestTags < JekyllUnitTest
end end
should "not cause an error" do should "not cause an error" do
refute_match(%r!markdown\-html\-error!, @result) refute_match(%r!markdown-html-error!, @result)
end end
should "have the URL to the 'yaml_with_dots' item" do should "have the URL to the 'yaml_with_dots' item" do
@ -639,7 +639,7 @@ class TestTags < JekyllUnitTest
end end
should "not cause an error" do should "not cause an error" do
refute_match(%r!markdown\-html\-error!, @result) refute_match(%r!markdown-html-error!, @result)
end end
should "have the URL to the 'sanitized_path' item" do should "have the URL to the 'sanitized_path' item" do

View File

@ -74,7 +74,7 @@ class TestTheme < JekyllUnitTest
should "raise when getting theme root" do should "raise when getting theme root" do
error = assert_raises(RuntimeError) { Theme.new("test-non-existent-theme") } error = assert_raises(RuntimeError) { Theme.new("test-non-existent-theme") }
assert_match(%r!fixtures\/test-non-existent-theme does not exist!, error.message) assert_match(%r!fixtures/test-non-existent-theme does not exist!, error.message)
end end
end end
end end