Configure and fix Style/ClassCheck cop.
This commit is contained in:
parent
c97d560b69
commit
5ce4e13ddd
|
@ -41,6 +41,10 @@ Naming/MemoizedInstanceVariableName:
|
||||||
- 'lib/zip/extra_field/old_unix.rb'
|
- 'lib/zip/extra_field/old_unix.rb'
|
||||||
- 'lib/zip/extra_field/unix.rb'
|
- 'lib/zip/extra_field/unix.rb'
|
||||||
|
|
||||||
|
# Set a consistent way of checking types.
|
||||||
|
Style/ClassCheck:
|
||||||
|
EnforcedStyle: kind_of?
|
||||||
|
|
||||||
# Allow this multi-line block chain as it actually reads better
|
# Allow this multi-line block chain as it actually reads better
|
||||||
# than the alternatives.
|
# than the alternatives.
|
||||||
Style/MultilineBlockChain:
|
Style/MultilineBlockChain:
|
||||||
|
|
|
@ -96,20 +96,6 @@ Style/ClassAndModuleChildren:
|
||||||
- 'lib/zip/extra_field/zip64.rb'
|
- 'lib/zip/extra_field/zip64.rb'
|
||||||
- 'lib/zip/extra_field/zip64_placeholder.rb'
|
- 'lib/zip/extra_field/zip64_placeholder.rb'
|
||||||
|
|
||||||
# Offense count: 15
|
|
||||||
# Cop supports --auto-correct.
|
|
||||||
# Configuration parameters: EnforcedStyle.
|
|
||||||
# SupportedStyles: is_a?, kind_of?
|
|
||||||
Style/ClassCheck:
|
|
||||||
Exclude:
|
|
||||||
- 'lib/zip/central_directory.rb'
|
|
||||||
- 'lib/zip/entry_set.rb'
|
|
||||||
- 'lib/zip/file.rb'
|
|
||||||
- 'lib/zip/output_stream.rb'
|
|
||||||
- 'test/filesystem/file_nonmutating_test.rb'
|
|
||||||
- 'test/ioextras/fake_io_test.rb'
|
|
||||||
- 'test/output_stream_test.rb'
|
|
||||||
|
|
||||||
# Offense count: 26
|
# Offense count: 26
|
||||||
Style/Documentation:
|
Style/Documentation:
|
||||||
Enabled: false
|
Enabled: false
|
||||||
|
|
|
@ -70,7 +70,7 @@ module Zip
|
||||||
@time = args[8] || ::Zip::DOSTime.now
|
@time = args[8] || ::Zip::DOSTime.now
|
||||||
|
|
||||||
@ftype = name_is_directory? ? :directory : :file
|
@ftype = name_is_directory? ? :directory : :file
|
||||||
@extra = ::Zip::ExtraField.new(@extra.to_s) unless @extra.is_a?(::Zip::ExtraField)
|
@extra = ::Zip::ExtraField.new(@extra.to_s) unless @extra.kind_of?(::Zip::ExtraField)
|
||||||
end
|
end
|
||||||
|
|
||||||
def encrypted?
|
def encrypted?
|
||||||
|
@ -271,7 +271,7 @@ module Zip
|
||||||
raise ::Zip::Error, 'Truncated local zip entry header'
|
raise ::Zip::Error, 'Truncated local zip entry header'
|
||||||
end
|
end
|
||||||
|
|
||||||
if @extra.is_a?(::Zip::ExtraField)
|
if @extra.kind_of?(::Zip::ExtraField)
|
||||||
@extra.merge(extra) if extra
|
@extra.merge(extra) if extra
|
||||||
else
|
else
|
||||||
@extra = ::Zip::ExtraField.new(extra)
|
@extra = ::Zip::ExtraField.new(extra)
|
||||||
|
@ -380,7 +380,7 @@ module Zip
|
||||||
end
|
end
|
||||||
|
|
||||||
def read_c_dir_extra_field(io)
|
def read_c_dir_extra_field(io)
|
||||||
if @extra.is_a?(::Zip::ExtraField)
|
if @extra.kind_of?(::Zip::ExtraField)
|
||||||
@extra.merge(io.read(@extra_length))
|
@extra.merge(io.read(@extra_length))
|
||||||
else
|
else
|
||||||
@extra = ::Zip::ExtraField.new(io.read(@extra_length))
|
@extra = ::Zip::ExtraField.new(io.read(@extra_length))
|
||||||
|
|
|
@ -141,11 +141,11 @@ module Zip
|
||||||
# (This can be used to extract data from a
|
# (This can be used to extract data from a
|
||||||
# downloaded zip archive without first saving it to disk.)
|
# downloaded zip archive without first saving it to disk.)
|
||||||
def open_buffer(io, options = {})
|
def open_buffer(io, options = {})
|
||||||
unless IO_METHODS.map { |method| io.respond_to?(method) }.all? || io.is_a?(String)
|
unless IO_METHODS.map { |method| io.respond_to?(method) }.all? || io.kind_of?(String)
|
||||||
raise "Zip::File.open_buffer expects a String or IO-like argument (responds to #{IO_METHODS.join(', ')}). Found: #{io.class}"
|
raise "Zip::File.open_buffer expects a String or IO-like argument (responds to #{IO_METHODS.join(', ')}). Found: #{io.class}"
|
||||||
end
|
end
|
||||||
|
|
||||||
io = ::StringIO.new(io) if io.is_a?(::String)
|
io = ::StringIO.new(io) if io.kind_of?(::String)
|
||||||
|
|
||||||
# https://github.com/rubyzip/rubyzip/issues/119
|
# https://github.com/rubyzip/rubyzip/issues/119
|
||||||
io.binmode if io.respond_to?(:binmode)
|
io.binmode if io.respond_to?(:binmode)
|
||||||
|
@ -344,7 +344,7 @@ module Zip
|
||||||
# Commits changes that has been made since the previous commit to
|
# Commits changes that has been made since the previous commit to
|
||||||
# the zip archive.
|
# the zip archive.
|
||||||
def commit
|
def commit
|
||||||
return if name.is_a?(StringIO) || !commit_required?
|
return if name.kind_of?(StringIO) || !commit_required?
|
||||||
|
|
||||||
on_success_replace do |tmp_file|
|
on_success_replace do |tmp_file|
|
||||||
::Zip::OutputStream.open(tmp_file) do |zos|
|
::Zip::OutputStream.open(tmp_file) do |zos|
|
||||||
|
|
|
@ -122,7 +122,7 @@ module Zip
|
||||||
|
|
||||||
def open_entry
|
def open_entry
|
||||||
@current_entry = ::Zip::Entry.read_local_entry(@archive_io)
|
@current_entry = ::Zip::Entry.read_local_entry(@archive_io)
|
||||||
if @current_entry && @current_entry.encrypted? && @decrypter.is_a?(NullEncrypter)
|
if @current_entry && @current_entry.encrypted? && @decrypter.kind_of?(NullEncrypter)
|
||||||
raise Error, 'password required to decode zip file'
|
raise Error, 'password required to decode zip file'
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -98,7 +98,7 @@ module Zip
|
||||||
end
|
end
|
||||||
new_entry.comment = comment unless comment.nil?
|
new_entry.comment = comment unless comment.nil?
|
||||||
unless extra.nil?
|
unless extra.nil?
|
||||||
new_entry.extra = extra.is_a?(ExtraField) ? extra : ExtraField.new(extra.to_s)
|
new_entry.extra = extra.kind_of?(ExtraField) ? extra : ExtraField.new(extra.to_s)
|
||||||
end
|
end
|
||||||
new_entry.compression_method = compression_method unless compression_method.nil?
|
new_entry.compression_method = compression_method unless compression_method.nil?
|
||||||
init_next_entry(new_entry, level)
|
init_next_entry(new_entry, level)
|
||||||
|
@ -108,7 +108,7 @@ module Zip
|
||||||
def copy_raw_entry(entry)
|
def copy_raw_entry(entry)
|
||||||
entry = entry.dup
|
entry = entry.dup
|
||||||
raise Error, 'zip stream is closed' if @closed
|
raise Error, 'zip stream is closed' if @closed
|
||||||
raise Error, 'entry is not a ZipEntry' unless entry.is_a?(Entry)
|
raise Error, 'entry is not a ZipEntry' unless entry.kind_of?(Entry)
|
||||||
|
|
||||||
finalize_current_entry
|
finalize_current_entry
|
||||||
@entry_set << entry
|
@entry_set << entry
|
||||||
|
|
|
@ -441,7 +441,7 @@ class ZipFsFileNonmutatingTest < MiniTest::Test
|
||||||
'*/foo/**/*.txt' => ['globTest/foo/bar/baz/foo.txt']
|
'*/foo/**/*.txt' => ['globTest/foo/bar/baz/foo.txt']
|
||||||
}.each do |spec, expected_results|
|
}.each do |spec, expected_results|
|
||||||
results = zf.glob(spec)
|
results = zf.glob(spec)
|
||||||
assert(results.all? { |entry| entry.is_a? ::Zip::Entry })
|
assert(results.all? { |entry| entry.kind_of? ::Zip::Entry })
|
||||||
|
|
||||||
result_strings = results.map(&:to_s)
|
result_strings = results.map(&:to_s)
|
||||||
missing_matches = expected_results - result_strings
|
missing_matches = expected_results - result_strings
|
||||||
|
|
Loading…
Reference in New Issue