From 6c46c21abbd45d25ba06b33155f8c72d2e3641b7 Mon Sep 17 00:00:00 2001 From: Pavel Lobashov Date: Sat, 21 Mar 2015 11:16:06 +0300 Subject: [PATCH] fix rubocop Style/ColonMethodCall cop --- .rubocop_rubyzip.yml | 5 ----- lib/zip/deflater.rb | 2 +- lib/zip/entry.rb | 6 +++--- lib/zip/pass_thru_compressor.rb | 4 ++-- test/file_extract_test.rb | 8 ++++---- test/file_split_test.rb | 8 ++++---- test/file_test.rb | 16 ++++++++-------- test/output_stream_test.rb | 2 +- 8 files changed, 23 insertions(+), 28 deletions(-) diff --git a/.rubocop_rubyzip.yml b/.rubocop_rubyzip.yml index 295481f..44fa63a 100644 --- a/.rubocop_rubyzip.yml +++ b/.rubocop_rubyzip.yml @@ -87,11 +87,6 @@ Style/ClassCheck: Style/ClassMethods: Enabled: false -# Offense count: 15 -# Cop supports --auto-correct. -Style/ColonMethodCall: - Enabled: false - # Offense count: 1 # Configuration parameters: Keywords. Style/CommentAnnotation: diff --git a/lib/zip/deflater.rb b/lib/zip/deflater.rb index ffcebb6..60ad215 100755 --- a/lib/zip/deflater.rb +++ b/lib/zip/deflater.rb @@ -13,7 +13,7 @@ module Zip def << (data) val = data.to_s - @crc = Zlib::crc32(val, @crc) + @crc = Zlib.crc32(val, @crc) @size += val.bytesize @buffer_stream << @zlib_deflater.deflate(data) end diff --git a/lib/zip/entry.rb b/lib/zip/entry.rb index e4ad83b..62bd064 100755 --- a/lib/zip/entry.rb +++ b/lib/zip/entry.rb @@ -374,9 +374,9 @@ module Zip def file_stat(path) # :nodoc: if @follow_symlinks - ::File::stat(path) + ::File.stat(path) else - ::File::lstat(path) + ::File.lstat(path) end end @@ -595,7 +595,7 @@ module Zip return if ::File.directory?(dest_path) if ::File.exist?(dest_path) if block_given? && yield(self, dest_path) - ::FileUtils::rm_f dest_path + ::FileUtils.rm_f dest_path else raise ::Zip::DestinationFileExistsError, "Cannot create directory '#{dest_path}'. "+ diff --git a/lib/zip/pass_thru_compressor.rb b/lib/zip/pass_thru_compressor.rb index 62b8636..2b429eb 100755 --- a/lib/zip/pass_thru_compressor.rb +++ b/lib/zip/pass_thru_compressor.rb @@ -3,13 +3,13 @@ module Zip def initialize(outputStream) super() @output_stream = outputStream - @crc = Zlib::crc32 + @crc = Zlib.crc32 @size = 0 end def << (data) val = data.to_s - @crc = Zlib::crc32(val, @crc) + @crc = Zlib.crc32(val, @crc) @size += val.bytesize @output_stream << val end diff --git a/test/file_extract_test.rb b/test/file_extract_test.rb index 4456aea..02270a7 100644 --- a/test/file_extract_test.rb +++ b/test/file_extract_test.rb @@ -15,8 +15,8 @@ class ZipFileExtractTest < MiniTest::Test zf.extract(ENTRY_TO_EXTRACT, EXTRACTED_FILENAME) assert(File.exist?(EXTRACTED_FILENAME)) - AssertEntry::assert_contents(EXTRACTED_FILENAME, - zf.get_input_stream(ENTRY_TO_EXTRACT) { |is| is.read }) + AssertEntry.assert_contents(EXTRACTED_FILENAME, + zf.get_input_stream(ENTRY_TO_EXTRACT) { |is| is.read }) ::File.unlink(EXTRACTED_FILENAME) @@ -25,8 +25,8 @@ class ZipFileExtractTest < MiniTest::Test entry.extract(EXTRACTED_FILENAME) assert(File.exist?(EXTRACTED_FILENAME)) - AssertEntry::assert_contents(EXTRACTED_FILENAME, - entry.get_input_stream() { |is| is.read }) + AssertEntry.assert_contents(EXTRACTED_FILENAME, + entry.get_input_stream() { |is| is.read }) end end diff --git a/test/file_split_test.rb b/test/file_split_test.rb index 66387aa..2b3c746 100644 --- a/test/file_split_test.rb +++ b/test/file_split_test.rb @@ -41,8 +41,8 @@ class ZipFileSplitTest < MiniTest::Test zf.extract(ENTRY_TO_EXTRACT, EXTRACTED_FILENAME) assert(File.exist?(EXTRACTED_FILENAME)) - AssertEntry::assert_contents(EXTRACTED_FILENAME, - zf.get_input_stream(ENTRY_TO_EXTRACT) { |is| is.read }) + AssertEntry.assert_contents(EXTRACTED_FILENAME, + zf.get_input_stream(ENTRY_TO_EXTRACT) { |is| is.read }) File.unlink(EXTRACTED_FILENAME) @@ -51,8 +51,8 @@ class ZipFileSplitTest < MiniTest::Test entry.extract(EXTRACTED_FILENAME) assert(File.exist?(EXTRACTED_FILENAME)) - AssertEntry::assert_contents(EXTRACTED_FILENAME, - entry.get_input_stream() { |is| is.read }) + AssertEntry.assert_contents(EXTRACTED_FILENAME, + entry.get_input_stream() { |is| is.read }) end end diff --git a/test/file_test.rb b/test/file_test.rb index 613c883..c1cae9b 100644 --- a/test/file_test.rb +++ b/test/file_test.rb @@ -293,14 +293,14 @@ class ZipFileTest < MiniTest::Test zf.close zfRead = ::Zip::File.new(TEST_ZIP.zip_name) - AssertEntry::assert_contents(newEntrySrcFilename, - zfRead.get_input_stream(entryToReplace) { |is| is.read }) - AssertEntry::assert_contents(TEST_ZIP.entry_names[0], - zfRead.get_input_stream(TEST_ZIP.entry_names[0]) { |is| is.read }) - AssertEntry::assert_contents(TEST_ZIP.entry_names[1], - zfRead.get_input_stream(TEST_ZIP.entry_names[1]) { |is| is.read }) - AssertEntry::assert_contents(TEST_ZIP.entry_names[3], - zfRead.get_input_stream(TEST_ZIP.entry_names[3]) { |is| is.read }) + AssertEntry.assert_contents(newEntrySrcFilename, + zfRead.get_input_stream(entryToReplace) { |is| is.read }) + AssertEntry.assert_contents(TEST_ZIP.entry_names[0], + zfRead.get_input_stream(TEST_ZIP.entry_names[0]) { |is| is.read }) + AssertEntry.assert_contents(TEST_ZIP.entry_names[1], + zfRead.get_input_stream(TEST_ZIP.entry_names[1]) { |is| is.read }) + AssertEntry.assert_contents(TEST_ZIP.entry_names[3], + zfRead.get_input_stream(TEST_ZIP.entry_names[3]) { |is| is.read }) zfRead.close end diff --git a/test/output_stream_test.rb b/test/output_stream_test.rb index fcb8ff3..f3f8ce1 100644 --- a/test/output_stream_test.rb +++ b/test/output_stream_test.rb @@ -88,7 +88,7 @@ class ZipOutputStreamTest < MiniTest::Test zos << file.read end - ::Zip::InputStream::open(TEST_ZIP.zip_name) do |io| + ::Zip::InputStream.open(TEST_ZIP.zip_name) do |io| while (entry = io.get_next_entry) assert(::Zip::DOSTime.at(file.mtime).dos_equals(::Zip::DOSTime.at(entry.mtime))) # Compare DOS Times, since they are stored with two seconds accuracy end