diff --git a/.rubocop.yml b/.rubocop.yml index 111c754..ccc5571 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -1,5 +1,9 @@ inherit_from: .rubocop_todo.yml +Layout/HashAlignment: + EnforcedHashRocketStyle: table + EnforcedColonStyle: table + # In some cases we just need to catch an exception, rather than # actually handle it. Allow the tests to make use of this shortcut. Lint/SuppressedException: diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index 8ecc67d..8563018 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -14,18 +14,6 @@ Layout/EmptyLinesAroundClassBody: Exclude: - 'test/extra_field_ut_test.rb' -# Offense count: 26 -# Cop supports --auto-correct. -# Configuration parameters: AllowMultipleStyles, EnforcedHashRocketStyle, EnforcedColonStyle, EnforcedLastArgumentHashStyle. -# SupportedHashRocketStyles: key, separator, table -# SupportedColonStyles: key, separator, table -# SupportedLastArgumentHashStyles: always_inspect, always_ignore, ignore_implicit, ignore_explicit -Layout/HashAlignment: - Exclude: - - 'lib/zip/constants.rb' - - 'lib/zip/file.rb' - - 'rubyzip.gemspec' - # Offense count: 120 Metrics/AbcSize: Max: 60 diff --git a/lib/zip/constants.rb b/lib/zip/constants.rb index 6feda25..428c512 100644 --- a/lib/zip/constants.rb +++ b/lib/zip/constants.rb @@ -87,29 +87,29 @@ module Zip COMPRESSION_METHOD_AES = 99 COMPRESSION_METHODS = { - COMPRESSION_METHOD_STORE => 'Store (no compression)', - COMPRESSION_METHOD_SHRINK => 'Shrink', - COMPRESSION_METHOD_REDUCE_1 => 'Reduce with compression factor 1', - COMPRESSION_METHOD_REDUCE_2 => 'Reduce with compression factor 2', - COMPRESSION_METHOD_REDUCE_3 => 'Reduce with compression factor 3', - COMPRESSION_METHOD_REDUCE_4 => 'Reduce with compression factor 4', - COMPRESSION_METHOD_IMPLODE => 'Implode', + COMPRESSION_METHOD_STORE => 'Store (no compression)', + COMPRESSION_METHOD_SHRINK => 'Shrink', + COMPRESSION_METHOD_REDUCE_1 => 'Reduce with compression factor 1', + COMPRESSION_METHOD_REDUCE_2 => 'Reduce with compression factor 2', + COMPRESSION_METHOD_REDUCE_3 => 'Reduce with compression factor 3', + COMPRESSION_METHOD_REDUCE_4 => 'Reduce with compression factor 4', + COMPRESSION_METHOD_IMPLODE => 'Implode', # RESERVED = 7 - COMPRESSION_METHOD_DEFLATE => 'Deflate', - COMPRESSION_METHOD_DEFLATE_64 => 'Deflate64(tm)', + COMPRESSION_METHOD_DEFLATE => 'Deflate', + COMPRESSION_METHOD_DEFLATE_64 => 'Deflate64(tm)', COMPRESSION_METHOD_PKWARE_DCLI => 'PKWARE Data Compression Library Imploding (old IBM TERSE)', # RESERVED = 11 - COMPRESSION_METHOD_BZIP2 => 'BZIP2', + COMPRESSION_METHOD_BZIP2 => 'BZIP2', # RESERVED = 13 - COMPRESSION_METHOD_LZMA => 'LZMA', + COMPRESSION_METHOD_LZMA => 'LZMA', # RESERVED = 15 - COMPRESSION_METHOD_IBM_CMPSC => 'IBM z/OS CMPSC Compression', + COMPRESSION_METHOD_IBM_CMPSC => 'IBM z/OS CMPSC Compression', # RESERVED = 17 - COMPRESSION_METHOD_IBM_TERSE => 'IBM TERSE (new)', - COMPRESSION_METHOD_IBM_LZ77 => 'IBM LZ77 z Architecture (PFS)', - COMPRESSION_METHOD_JPEG => 'JPEG variant', - COMPRESSION_METHOD_WAVPACK => 'WavPack compressed data', - COMPRESSION_METHOD_PPMD => 'PPMd version I, Rev 1', - COMPRESSION_METHOD_AES => 'AES encryption', + COMPRESSION_METHOD_IBM_TERSE => 'IBM TERSE (new)', + COMPRESSION_METHOD_IBM_LZ77 => 'IBM LZ77 z Architecture (PFS)', + COMPRESSION_METHOD_JPEG => 'JPEG variant', + COMPRESSION_METHOD_WAVPACK => 'WavPack compressed data', + COMPRESSION_METHOD_PPMD => 'PPMd version I, Rev 1', + COMPRESSION_METHOD_AES => 'AES encryption', }.freeze end diff --git a/test/filesystem/file_nonmutating_test.rb b/test/filesystem/file_nonmutating_test.rb index e416eec..af575fa 100644 --- a/test/filesystem/file_nonmutating_test.rb +++ b/test/filesystem/file_nonmutating_test.rb @@ -434,9 +434,11 @@ class ZipFsFileNonmutatingTest < MiniTest::Test ::Zip::File.open('test/data/globTest.zip') do |zf| { 'globTest/foo.txt' => ['globTest/foo.txt'], - '*/foo.txt' => ['globTest/foo.txt'], - '**/foo.txt' => ['globTest/foo.txt', 'globTest/foo/bar/baz/foo.txt'], - '*/foo/**/*.txt' => ['globTest/foo/bar/baz/foo.txt'] + '*/foo.txt' => ['globTest/foo.txt'], + '**/foo.txt' => [ + 'globTest/foo.txt', 'globTest/foo/bar/baz/foo.txt' + ], + '*/foo/**/*.txt' => ['globTest/foo/bar/baz/foo.txt'] }.each do |spec, expected_results| results = zf.glob(spec) assert(results.all? { |entry| entry.is_a? ::Zip::Entry }) diff --git a/test/path_traversal_test.rb b/test/path_traversal_test.rb index 6950fbc..47c7e30 100644 --- a/test/path_traversal_test.rb +++ b/test/path_traversal_test.rb @@ -62,7 +62,7 @@ class PathTraversalTest < MiniTest::Test def test_non_leading_dot_dot_with_existing_folder entries = { - 'tmp/' => '', + 'tmp/' => '', 'tmp/../../moo' => /WARNING: skipped \'tmp\/\.\.\/\.\.\/moo\'/ } in_tmpdir do @@ -92,7 +92,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 @@ -104,8 +104,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 @@ -119,7 +119,7 @@ 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' => /WARNING: skipped symlink \'cur\'/, 'cur/par' => /WARNING: skipped symlink \'cur\/par\'/, 'par/moo' => :error } @@ -132,7 +132,7 @@ class PathTraversalTest < MiniTest::Test def test_entry_name_with_absolute_path_does_not_extract entries = { - '/tmp/' => /WARNING: skipped \'\/tmp\/\'/, + '/tmp/' => /WARNING: skipped \'\/tmp\/\'/, '/tmp/file.txt' => /WARNING: skipped \'\/tmp\/file.txt\'/ } in_tmpdir do @@ -156,7 +156,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