Fix Style/RedundantRegexpEscape cop.

This commit is contained in:
Robert Haines 2021-06-18 16:31:23 +01:00
parent f1e8c2fc9d
commit a2a14c2cd2
4 changed files with 15 additions and 23 deletions

View File

@ -114,14 +114,6 @@ Style/OptionalBooleanParameter:
- 'lib/zip/file_split.rb'
- 'lib/zip/output_stream.rb'
# Offense count: 29
# Cop supports --auto-correct.
Style/RedundantRegexpEscape:
Exclude:
- 'Guardfile'
- 'test/file_extract_test.rb'
- 'test/path_traversal_test.rb'
# Offense count: 17
# Cop supports --auto-correct.
# Configuration parameters: ConvertCodeThatCanStartToReturnNil, AllowedMethods.

View File

@ -2,7 +2,7 @@
guard :minitest do
# with Minitest::Unit
watch(%r{^test/(.*)\/?(.*)_test\.rb$})
watch(%r{^test/(.*)/?(.*)_test\.rb$})
watch(%r{^lib/zip/(.*/)?([^/]+)\.rb$}) { |m| "test/#{m[1]}#{m[2]}_test.rb" }
watch(%r{^test/test_helper\.rb$}) { 'test' }
end

View File

@ -129,7 +129,7 @@ class ZipFileExtractTest < MiniTest::Test
assert_equal fake_size, a_entry.size
::Zip.validate_entry_sizes = false
assert_output('', /.+\'a\'.+1B.+/) do
assert_output('', /.+'a'.+1B.+/) do
a_entry.extract
end
assert_equal true_size, File.size(file_name)

View File

@ -39,7 +39,7 @@ class PathTraversalTest < MiniTest::Test
end
def test_leading_slash
entries = { '/tmp/moo' => /WARNING: skipped \'\/tmp\/moo\'/ }
entries = { '/tmp/moo' => /WARNING: skipped '\/tmp\/moo'/ }
in_tmpdir do
extract_paths(['jwilk', 'absolute1.zip'], entries)
refute File.exist?('/tmp/moo')
@ -47,7 +47,7 @@ class PathTraversalTest < MiniTest::Test
end
def test_multiple_leading_slashes
entries = { '//tmp/moo' => /WARNING: skipped \'\/\/tmp\/moo\'/ }
entries = { '//tmp/moo' => /WARNING: skipped '\/\/tmp\/moo'/ }
in_tmpdir do
extract_paths(['jwilk', 'absolute2.zip'], entries)
refute File.exist?('/tmp/moo')
@ -55,7 +55,7 @@ class PathTraversalTest < MiniTest::Test
end
def test_leading_dot_dot
entries = { '../moo' => /WARNING: skipped \'\.\.\/moo\'/ }
entries = { '../moo' => /WARNING: skipped '\.\.\/moo'/ }
in_tmpdir do
extract_paths(['jwilk', 'relative0.zip'], entries)
refute File.exist?('../moo')
@ -65,7 +65,7 @@ class PathTraversalTest < MiniTest::Test
def test_non_leading_dot_dot_with_existing_folder
entries = {
'tmp/' => '',
'tmp/../../moo' => /WARNING: skipped \'tmp\/\.\.\/\.\.\/moo\'/
'tmp/../../moo' => /WARNING: skipped 'tmp\/\.\.\/\.\.\/moo'/
}
in_tmpdir do
extract_paths('relative1.zip', entries)
@ -75,7 +75,7 @@ class PathTraversalTest < MiniTest::Test
end
def test_non_leading_dot_dot_without_existing_folder
entries = { 'tmp/../../moo' => /WARNING: skipped \'tmp\/\.\.\/\.\.\/moo\'/ }
entries = { 'tmp/../../moo' => /WARNING: skipped 'tmp\/\.\.\/\.\.\/moo'/ }
in_tmpdir do
extract_paths(['jwilk', 'relative2.zip'], entries)
refute File.exist?('../moo')
@ -94,7 +94,7 @@ class PathTraversalTest < MiniTest::Test
def test_directory_symlink
# Can't create tmp/moo, because the tmp symlink is skipped.
entries = {
'tmp' => /WARNING: skipped symlink \'tmp\'/,
'tmp' => /WARNING: skipped symlink 'tmp'/,
'tmp/moo' => :error
}
in_tmpdir do
@ -106,8 +106,8 @@ class PathTraversalTest < MiniTest::Test
def test_two_directory_symlinks_a
# Can't create par/moo because the symlinks are skipped.
entries = {
'cur' => /WARNING: skipped symlink \'cur\'/,
'par' => /WARNING: skipped symlink \'par\'/,
'cur' => /WARNING: skipped symlink 'cur'/,
'par' => /WARNING: skipped symlink 'par'/,
'par/moo' => :error
}
in_tmpdir do
@ -121,8 +121,8 @@ class PathTraversalTest < MiniTest::Test
def test_two_directory_symlinks_b
# Can't create par/moo, because the symlinks are skipped.
entries = {
'cur' => /WARNING: skipped symlink \'cur\'/,
'cur/par' => /WARNING: skipped symlink \'cur\/par\'/,
'cur' => /WARNING: skipped symlink 'cur'/,
'cur/par' => /WARNING: skipped symlink 'cur\/par'/,
'par/moo' => :error
}
in_tmpdir do
@ -134,8 +134,8 @@ class PathTraversalTest < MiniTest::Test
def test_entry_name_with_absolute_path_does_not_extract
entries = {
'/tmp/' => /WARNING: skipped \'\/tmp\/\'/,
'/tmp/file.txt' => /WARNING: skipped \'\/tmp\/file.txt\'/
'/tmp/' => /WARNING: skipped '\/tmp\/'/,
'/tmp/file.txt' => /WARNING: skipped '\/tmp\/file.txt'/
}
in_tmpdir do
extract_paths(['tuzovakaoff', 'absolutepath.zip'], entries)
@ -158,7 +158,7 @@ class PathTraversalTest < MiniTest::Test
def test_entry_name_with_relative_symlink
# Doesn't create the symlink path, so can't create path/file.txt.
entries = {
'path' => /WARNING: skipped symlink \'path\'/,
'path' => /WARNING: skipped symlink 'path'/,
'path/file.txt' => :error
}
in_tmpdir do