diff --git a/.rubocop_rubyzip.yml b/.rubocop_rubyzip.yml index b892bbe3..3030f8a0 100644 --- a/.rubocop_rubyzip.yml +++ b/.rubocop_rubyzip.yml @@ -73,6 +73,12 @@ Style/BlockDelimiters: Style/ClassAndModuleChildren: Enabled: false +# Offense count: 15 +# Cop supports --auto-correct. +# Configuration parameters: EnforcedStyle, SupportedStyles. +Style/ClassCheck: + Enabled: false + # Offense count: 77 Style/Documentation: Enabled: false diff --git a/lib/zip/central_directory.rb b/lib/zip/central_directory.rb index 5b0a3fe6..cb7e2da7 100644 --- a/lib/zip/central_directory.rb +++ b/lib/zip/central_directory.rb @@ -17,7 +17,7 @@ def entries def initialize(entries = EntrySet.new, comment = '') #:nodoc: super() - @entry_set = entries.is_a?(EntrySet) ? entries : EntrySet.new(entries) + @entry_set = entries.kind_of?(EntrySet) ? entries : EntrySet.new(entries) @comment = comment end @@ -197,7 +197,7 @@ def self.read_from_stream(io) #:nodoc: end def ==(other) #:nodoc: - return false unless other.is_a?(CentralDirectory) + return false unless other.kind_of?(CentralDirectory) @entry_set.entries.sort == other.entries.sort && comment == other.comment end end diff --git a/lib/zip/entry_set.rb b/lib/zip/entry_set.rb index e083b0e2..dc6e53e2 100644 --- a/lib/zip/entry_set.rb +++ b/lib/zip/entry_set.rb @@ -49,7 +49,7 @@ def dup end def ==(other) - return false unless other.is_a?(EntrySet) + return false unless other.kind_of?(EntrySet) @entry_set.values == other.entry_set.values end diff --git a/lib/zip/file.rb b/lib/zip/file.rb index 16cfc005..3cc4c352 100644 --- a/lib/zip/file.rb +++ b/lib/zip/file.rb @@ -235,7 +235,7 @@ def get_input_stream(entry, &aProc) # File.open method. def get_output_stream(entry, permission_int = nil, comment = nil, extra = nil, compressed_size = nil, crc = nil, compression_method = nil, size = nil, time = nil, &aProc) new_entry = - if entry.is_a?(Entry) + if entry.kind_of?(Entry) entry else Entry.new(@name, entry.to_s, comment, extra, compressed_size, crc, compression_method, size, time) @@ -264,7 +264,7 @@ def read(entry) def add(entry, src_path, &continue_on_exists_proc) continue_on_exists_proc ||= proc { ::Zip.continue_on_exists_proc } check_entry_exists(entry, continue_on_exists_proc, 'add') - new_entry = entry.is_a?(::Zip::Entry) ? entry : ::Zip::Entry.new(@name, entry.to_s) + new_entry = entry.kind_of?(::Zip::Entry) ? entry : ::Zip::Entry.new(@name, entry.to_s) new_entry.gather_fileinfo_from_srcpath(src_path) new_entry.dirty = true @entry_set << new_entry diff --git a/lib/zip/output_stream.rb b/lib/zip/output_stream.rb index c320566f..70117e24 100644 --- a/lib/zip/output_stream.rb +++ b/lib/zip/output_stream.rb @@ -87,7 +87,7 @@ def close_buffer # +entry+ can be a ZipEntry object or a string. def put_next_entry(entry_name, comment = nil, extra = nil, compression_method = Entry::DEFLATED, level = Zip.default_compression) raise Error, 'zip stream is closed' if @closed - if entry_name.is_a?(Entry) + if entry_name.kind_of?(Entry) new_entry = entry_name else new_entry = Entry.new(@file_name, entry_name.to_s) diff --git a/test/filesystem/file_nonmutating_test.rb b/test/filesystem/file_nonmutating_test.rb index 7ce00021..50184b78 100644 --- a/test/filesystem/file_nonmutating_test.rb +++ b/test/filesystem/file_nonmutating_test.rb @@ -384,7 +384,7 @@ def test_readlink def test_stat s = @zip_file.file.stat('file1') - assert(s.is_a?(File::Stat)) # It pretends + assert(s.kind_of?(File::Stat)) # It pretends assert_raises(Errno::ENOENT, 'No such file or directory - noSuchFile') do @zip_file.file.stat('noSuchFile') end diff --git a/test/ioextras/fake_io_test.rb b/test/ioextras/fake_io_test.rb index 04059715..00726c48 100644 --- a/test/ioextras/fake_io_test.rb +++ b/test/ioextras/fake_io_test.rb @@ -9,10 +9,10 @@ class FakeIOUsingClass def test_kind_of? obj = FakeIOUsingClass.new - assert(obj.is_a?(Object)) - assert(obj.is_a?(FakeIOUsingClass)) - assert(obj.is_a?(IO)) - assert(!obj.is_a?(Fixnum)) - assert(!obj.is_a?(String)) + assert(obj.kind_of?(Object)) + assert(obj.kind_of?(FakeIOUsingClass)) + assert(obj.kind_of?(IO)) + assert(!obj.kind_of?(Fixnum)) + assert(!obj.kind_of?(String)) end end diff --git a/test/output_stream_test.rb b/test/output_stream_test.rb index f6ff55d2..a7725e22 100644 --- a/test/output_stream_test.rb +++ b/test/output_stream_test.rb @@ -58,9 +58,9 @@ def test_cannot_open_file begin ::Zip::OutputStream.open(name) rescue Exception - assert($!.is_a?(Errno::EISDIR) || # Linux - $!.is_a?(Errno::EEXIST) || # Windows/cygwin - $!.is_a?(Errno::EACCES), # Windows + assert($!.kind_of?(Errno::EISDIR) || # Linux + $!.kind_of?(Errno::EEXIST) || # Windows/cygwin + $!.kind_of?(Errno::EACCES), # Windows "Expected Errno::EISDIR (or on win/cygwin: Errno::EEXIST), but was: #{$!.class}") end end