fix rubocop Style/ColonMethodCall cop

This commit is contained in:
Pavel Lobashov 2015-03-21 11:16:06 +03:00
parent a0da550c22
commit 6c46c21abb
8 changed files with 23 additions and 28 deletions

View File

@ -87,11 +87,6 @@ Style/ClassCheck:
Style/ClassMethods: Style/ClassMethods:
Enabled: false Enabled: false
# Offense count: 15
# Cop supports --auto-correct.
Style/ColonMethodCall:
Enabled: false
# Offense count: 1 # Offense count: 1
# Configuration parameters: Keywords. # Configuration parameters: Keywords.
Style/CommentAnnotation: Style/CommentAnnotation:

View File

@ -13,7 +13,7 @@ module Zip
def << (data) def << (data)
val = data.to_s val = data.to_s
@crc = Zlib::crc32(val, @crc) @crc = Zlib.crc32(val, @crc)
@size += val.bytesize @size += val.bytesize
@buffer_stream << @zlib_deflater.deflate(data) @buffer_stream << @zlib_deflater.deflate(data)
end end

View File

@ -374,9 +374,9 @@ module Zip
def file_stat(path) # :nodoc: def file_stat(path) # :nodoc:
if @follow_symlinks if @follow_symlinks
::File::stat(path) ::File.stat(path)
else else
::File::lstat(path) ::File.lstat(path)
end end
end end
@ -595,7 +595,7 @@ module Zip
return if ::File.directory?(dest_path) return if ::File.directory?(dest_path)
if ::File.exist?(dest_path) if ::File.exist?(dest_path)
if block_given? && yield(self, dest_path) if block_given? && yield(self, dest_path)
::FileUtils::rm_f dest_path ::FileUtils.rm_f dest_path
else else
raise ::Zip::DestinationFileExistsError, raise ::Zip::DestinationFileExistsError,
"Cannot create directory '#{dest_path}'. "+ "Cannot create directory '#{dest_path}'. "+

View File

@ -3,13 +3,13 @@ module Zip
def initialize(outputStream) def initialize(outputStream)
super() super()
@output_stream = outputStream @output_stream = outputStream
@crc = Zlib::crc32 @crc = Zlib.crc32
@size = 0 @size = 0
end end
def << (data) def << (data)
val = data.to_s val = data.to_s
@crc = Zlib::crc32(val, @crc) @crc = Zlib.crc32(val, @crc)
@size += val.bytesize @size += val.bytesize
@output_stream << val @output_stream << val
end end

View File

@ -15,7 +15,7 @@ class ZipFileExtractTest < MiniTest::Test
zf.extract(ENTRY_TO_EXTRACT, EXTRACTED_FILENAME) zf.extract(ENTRY_TO_EXTRACT, EXTRACTED_FILENAME)
assert(File.exist?(EXTRACTED_FILENAME)) assert(File.exist?(EXTRACTED_FILENAME))
AssertEntry::assert_contents(EXTRACTED_FILENAME, AssertEntry.assert_contents(EXTRACTED_FILENAME,
zf.get_input_stream(ENTRY_TO_EXTRACT) { |is| is.read }) zf.get_input_stream(ENTRY_TO_EXTRACT) { |is| is.read })
@ -25,7 +25,7 @@ class ZipFileExtractTest < MiniTest::Test
entry.extract(EXTRACTED_FILENAME) entry.extract(EXTRACTED_FILENAME)
assert(File.exist?(EXTRACTED_FILENAME)) assert(File.exist?(EXTRACTED_FILENAME))
AssertEntry::assert_contents(EXTRACTED_FILENAME, AssertEntry.assert_contents(EXTRACTED_FILENAME,
entry.get_input_stream() { |is| is.read }) entry.get_input_stream() { |is| is.read })
end end

View File

@ -41,7 +41,7 @@ class ZipFileSplitTest < MiniTest::Test
zf.extract(ENTRY_TO_EXTRACT, EXTRACTED_FILENAME) zf.extract(ENTRY_TO_EXTRACT, EXTRACTED_FILENAME)
assert(File.exist?(EXTRACTED_FILENAME)) assert(File.exist?(EXTRACTED_FILENAME))
AssertEntry::assert_contents(EXTRACTED_FILENAME, AssertEntry.assert_contents(EXTRACTED_FILENAME,
zf.get_input_stream(ENTRY_TO_EXTRACT) { |is| is.read }) zf.get_input_stream(ENTRY_TO_EXTRACT) { |is| is.read })
@ -51,7 +51,7 @@ class ZipFileSplitTest < MiniTest::Test
entry.extract(EXTRACTED_FILENAME) entry.extract(EXTRACTED_FILENAME)
assert(File.exist?(EXTRACTED_FILENAME)) assert(File.exist?(EXTRACTED_FILENAME))
AssertEntry::assert_contents(EXTRACTED_FILENAME, AssertEntry.assert_contents(EXTRACTED_FILENAME,
entry.get_input_stream() { |is| is.read }) entry.get_input_stream() { |is| is.read })
end end

View File

@ -293,13 +293,13 @@ class ZipFileTest < MiniTest::Test
zf.close zf.close
zfRead = ::Zip::File.new(TEST_ZIP.zip_name) zfRead = ::Zip::File.new(TEST_ZIP.zip_name)
AssertEntry::assert_contents(newEntrySrcFilename, AssertEntry.assert_contents(newEntrySrcFilename,
zfRead.get_input_stream(entryToReplace) { |is| is.read }) zfRead.get_input_stream(entryToReplace) { |is| is.read })
AssertEntry::assert_contents(TEST_ZIP.entry_names[0], AssertEntry.assert_contents(TEST_ZIP.entry_names[0],
zfRead.get_input_stream(TEST_ZIP.entry_names[0]) { |is| is.read }) zfRead.get_input_stream(TEST_ZIP.entry_names[0]) { |is| is.read })
AssertEntry::assert_contents(TEST_ZIP.entry_names[1], AssertEntry.assert_contents(TEST_ZIP.entry_names[1],
zfRead.get_input_stream(TEST_ZIP.entry_names[1]) { |is| is.read }) zfRead.get_input_stream(TEST_ZIP.entry_names[1]) { |is| is.read })
AssertEntry::assert_contents(TEST_ZIP.entry_names[3], AssertEntry.assert_contents(TEST_ZIP.entry_names[3],
zfRead.get_input_stream(TEST_ZIP.entry_names[3]) { |is| is.read }) zfRead.get_input_stream(TEST_ZIP.entry_names[3]) { |is| is.read })
zfRead.close zfRead.close
end end

View File

@ -88,7 +88,7 @@ class ZipOutputStreamTest < MiniTest::Test
zos << file.read zos << file.read
end 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) 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 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 end