Fix Style/RedundantRegexpEscape cop.
This commit is contained in:
parent
f1e8c2fc9d
commit
a2a14c2cd2
|
@ -114,14 +114,6 @@ Style/OptionalBooleanParameter:
|
||||||
- 'lib/zip/file_split.rb'
|
- 'lib/zip/file_split.rb'
|
||||||
- 'lib/zip/output_stream.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
|
# Offense count: 17
|
||||||
# Cop supports --auto-correct.
|
# Cop supports --auto-correct.
|
||||||
# Configuration parameters: ConvertCodeThatCanStartToReturnNil, AllowedMethods.
|
# Configuration parameters: ConvertCodeThatCanStartToReturnNil, AllowedMethods.
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
|
|
||||||
guard :minitest do
|
guard :minitest do
|
||||||
# with Minitest::Unit
|
# 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{^lib/zip/(.*/)?([^/]+)\.rb$}) { |m| "test/#{m[1]}#{m[2]}_test.rb" }
|
||||||
watch(%r{^test/test_helper\.rb$}) { 'test' }
|
watch(%r{^test/test_helper\.rb$}) { 'test' }
|
||||||
end
|
end
|
||||||
|
|
|
@ -129,7 +129,7 @@ class ZipFileExtractTest < MiniTest::Test
|
||||||
assert_equal fake_size, a_entry.size
|
assert_equal fake_size, a_entry.size
|
||||||
|
|
||||||
::Zip.validate_entry_sizes = false
|
::Zip.validate_entry_sizes = false
|
||||||
assert_output('', /.+\'a\'.+1B.+/) do
|
assert_output('', /.+'a'.+1B.+/) do
|
||||||
a_entry.extract
|
a_entry.extract
|
||||||
end
|
end
|
||||||
assert_equal true_size, File.size(file_name)
|
assert_equal true_size, File.size(file_name)
|
||||||
|
|
|
@ -39,7 +39,7 @@ class PathTraversalTest < MiniTest::Test
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_leading_slash
|
def test_leading_slash
|
||||||
entries = { '/tmp/moo' => /WARNING: skipped \'\/tmp\/moo\'/ }
|
entries = { '/tmp/moo' => /WARNING: skipped '\/tmp\/moo'/ }
|
||||||
in_tmpdir do
|
in_tmpdir do
|
||||||
extract_paths(['jwilk', 'absolute1.zip'], entries)
|
extract_paths(['jwilk', 'absolute1.zip'], entries)
|
||||||
refute File.exist?('/tmp/moo')
|
refute File.exist?('/tmp/moo')
|
||||||
|
@ -47,7 +47,7 @@ class PathTraversalTest < MiniTest::Test
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_multiple_leading_slashes
|
def test_multiple_leading_slashes
|
||||||
entries = { '//tmp/moo' => /WARNING: skipped \'\/\/tmp\/moo\'/ }
|
entries = { '//tmp/moo' => /WARNING: skipped '\/\/tmp\/moo'/ }
|
||||||
in_tmpdir do
|
in_tmpdir do
|
||||||
extract_paths(['jwilk', 'absolute2.zip'], entries)
|
extract_paths(['jwilk', 'absolute2.zip'], entries)
|
||||||
refute File.exist?('/tmp/moo')
|
refute File.exist?('/tmp/moo')
|
||||||
|
@ -55,7 +55,7 @@ class PathTraversalTest < MiniTest::Test
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_leading_dot_dot
|
def test_leading_dot_dot
|
||||||
entries = { '../moo' => /WARNING: skipped \'\.\.\/moo\'/ }
|
entries = { '../moo' => /WARNING: skipped '\.\.\/moo'/ }
|
||||||
in_tmpdir do
|
in_tmpdir do
|
||||||
extract_paths(['jwilk', 'relative0.zip'], entries)
|
extract_paths(['jwilk', 'relative0.zip'], entries)
|
||||||
refute File.exist?('../moo')
|
refute File.exist?('../moo')
|
||||||
|
@ -65,7 +65,7 @@ class PathTraversalTest < MiniTest::Test
|
||||||
def test_non_leading_dot_dot_with_existing_folder
|
def test_non_leading_dot_dot_with_existing_folder
|
||||||
entries = {
|
entries = {
|
||||||
'tmp/' => '',
|
'tmp/' => '',
|
||||||
'tmp/../../moo' => /WARNING: skipped \'tmp\/\.\.\/\.\.\/moo\'/
|
'tmp/../../moo' => /WARNING: skipped 'tmp\/\.\.\/\.\.\/moo'/
|
||||||
}
|
}
|
||||||
in_tmpdir do
|
in_tmpdir do
|
||||||
extract_paths('relative1.zip', entries)
|
extract_paths('relative1.zip', entries)
|
||||||
|
@ -75,7 +75,7 @@ class PathTraversalTest < MiniTest::Test
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_non_leading_dot_dot_without_existing_folder
|
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
|
in_tmpdir do
|
||||||
extract_paths(['jwilk', 'relative2.zip'], entries)
|
extract_paths(['jwilk', 'relative2.zip'], entries)
|
||||||
refute File.exist?('../moo')
|
refute File.exist?('../moo')
|
||||||
|
@ -94,7 +94,7 @@ class PathTraversalTest < MiniTest::Test
|
||||||
def test_directory_symlink
|
def test_directory_symlink
|
||||||
# Can't create tmp/moo, because the tmp symlink is skipped.
|
# Can't create tmp/moo, because the tmp symlink is skipped.
|
||||||
entries = {
|
entries = {
|
||||||
'tmp' => /WARNING: skipped symlink \'tmp\'/,
|
'tmp' => /WARNING: skipped symlink 'tmp'/,
|
||||||
'tmp/moo' => :error
|
'tmp/moo' => :error
|
||||||
}
|
}
|
||||||
in_tmpdir do
|
in_tmpdir do
|
||||||
|
@ -106,8 +106,8 @@ class PathTraversalTest < MiniTest::Test
|
||||||
def test_two_directory_symlinks_a
|
def test_two_directory_symlinks_a
|
||||||
# Can't create par/moo because the symlinks are skipped.
|
# Can't create par/moo because the symlinks are skipped.
|
||||||
entries = {
|
entries = {
|
||||||
'cur' => /WARNING: skipped symlink \'cur\'/,
|
'cur' => /WARNING: skipped symlink 'cur'/,
|
||||||
'par' => /WARNING: skipped symlink \'par\'/,
|
'par' => /WARNING: skipped symlink 'par'/,
|
||||||
'par/moo' => :error
|
'par/moo' => :error
|
||||||
}
|
}
|
||||||
in_tmpdir do
|
in_tmpdir do
|
||||||
|
@ -121,8 +121,8 @@ class PathTraversalTest < MiniTest::Test
|
||||||
def test_two_directory_symlinks_b
|
def test_two_directory_symlinks_b
|
||||||
# Can't create par/moo, because the symlinks are skipped.
|
# Can't create par/moo, because the symlinks are skipped.
|
||||||
entries = {
|
entries = {
|
||||||
'cur' => /WARNING: skipped symlink \'cur\'/,
|
'cur' => /WARNING: skipped symlink 'cur'/,
|
||||||
'cur/par' => /WARNING: skipped symlink \'cur\/par\'/,
|
'cur/par' => /WARNING: skipped symlink 'cur\/par'/,
|
||||||
'par/moo' => :error
|
'par/moo' => :error
|
||||||
}
|
}
|
||||||
in_tmpdir do
|
in_tmpdir do
|
||||||
|
@ -134,8 +134,8 @@ class PathTraversalTest < MiniTest::Test
|
||||||
|
|
||||||
def test_entry_name_with_absolute_path_does_not_extract
|
def test_entry_name_with_absolute_path_does_not_extract
|
||||||
entries = {
|
entries = {
|
||||||
'/tmp/' => /WARNING: skipped \'\/tmp\/\'/,
|
'/tmp/' => /WARNING: skipped '\/tmp\/'/,
|
||||||
'/tmp/file.txt' => /WARNING: skipped \'\/tmp\/file.txt\'/
|
'/tmp/file.txt' => /WARNING: skipped '\/tmp\/file.txt'/
|
||||||
}
|
}
|
||||||
in_tmpdir do
|
in_tmpdir do
|
||||||
extract_paths(['tuzovakaoff', 'absolutepath.zip'], entries)
|
extract_paths(['tuzovakaoff', 'absolutepath.zip'], entries)
|
||||||
|
@ -158,7 +158,7 @@ class PathTraversalTest < MiniTest::Test
|
||||||
def test_entry_name_with_relative_symlink
|
def test_entry_name_with_relative_symlink
|
||||||
# Doesn't create the symlink path, so can't create path/file.txt.
|
# Doesn't create the symlink path, so can't create path/file.txt.
|
||||||
entries = {
|
entries = {
|
||||||
'path' => /WARNING: skipped symlink \'path\'/,
|
'path' => /WARNING: skipped symlink 'path'/,
|
||||||
'path/file.txt' => :error
|
'path/file.txt' => :error
|
||||||
}
|
}
|
||||||
in_tmpdir do
|
in_tmpdir do
|
||||||
|
|
Loading…
Reference in New Issue