fix rubocop Style/GuardClause cop
This commit is contained in:
parent
63b3ee3465
commit
b920a1eb49
|
@ -139,11 +139,6 @@ Style/FileName:
|
||||||
Style/FormatString:
|
Style/FormatString:
|
||||||
Enabled: false
|
Enabled: false
|
||||||
|
|
||||||
# Offense count: 10
|
|
||||||
# Configuration parameters: MinBodyLength.
|
|
||||||
Style/GuardClause:
|
|
||||||
Enabled: false
|
|
||||||
|
|
||||||
# Offense count: 1
|
# Offense count: 1
|
||||||
# Cop supports --auto-correct.
|
# Cop supports --auto-correct.
|
||||||
Style/InfiniteLoop:
|
Style/InfiniteLoop:
|
||||||
|
|
|
@ -45,10 +45,9 @@ module Zip
|
||||||
end
|
end
|
||||||
|
|
||||||
def check_name(name)
|
def check_name(name)
|
||||||
if name.start_with?('/')
|
return unless name.start_with?('/')
|
||||||
raise ::Zip::EntryNameError, "Illegal ZipEntry name '#{name}', name must not start with /"
|
raise ::Zip::EntryNameError, "Illegal ZipEntry name '#{name}', name must not start with /"
|
||||||
end
|
end
|
||||||
end
|
|
||||||
|
|
||||||
def initialize(*args)
|
def initialize(*args)
|
||||||
name = args[1] || ''
|
name = args[1] || ''
|
||||||
|
@ -332,22 +331,19 @@ module Zip
|
||||||
end
|
end
|
||||||
|
|
||||||
def check_c_dir_entry_static_header_length(buf)
|
def check_c_dir_entry_static_header_length(buf)
|
||||||
unless buf.bytesize == ::Zip::CDIR_ENTRY_STATIC_HEADER_LENGTH
|
return if buf.bytesize == ::Zip::CDIR_ENTRY_STATIC_HEADER_LENGTH
|
||||||
raise Error, 'Premature end of file. Not enough data for zip cdir entry header'
|
raise Error, 'Premature end of file. Not enough data for zip cdir entry header'
|
||||||
end
|
end
|
||||||
end
|
|
||||||
|
|
||||||
def check_c_dir_entry_signature
|
def check_c_dir_entry_signature
|
||||||
unless header_signature == ::Zip::CENTRAL_DIRECTORY_ENTRY_SIGNATURE
|
return if header_signature == ::Zip::CENTRAL_DIRECTORY_ENTRY_SIGNATURE
|
||||||
raise Error, "Zip local header magic not found at location '#{local_header_offset}'"
|
raise Error, "Zip local header magic not found at location '#{local_header_offset}'"
|
||||||
end
|
end
|
||||||
end
|
|
||||||
|
|
||||||
def check_c_dir_entry_comment_size
|
def check_c_dir_entry_comment_size
|
||||||
unless @comment && @comment.bytesize == @comment_length
|
return if @comment && @comment.bytesize == @comment_length
|
||||||
raise ::Zip::Error, 'Truncated cdir zip entry header'
|
raise ::Zip::Error, 'Truncated cdir zip entry header'
|
||||||
end
|
end
|
||||||
end
|
|
||||||
|
|
||||||
def read_c_dir_extra_field(io)
|
def read_c_dir_extra_field(io)
|
||||||
if @extra.is_a?(::Zip::ExtraField)
|
if @extra.is_a?(::Zip::ExtraField)
|
||||||
|
@ -380,13 +376,12 @@ module Zip
|
||||||
end
|
end
|
||||||
|
|
||||||
def get_extra_attributes_from_path(path) # :nodoc:
|
def get_extra_attributes_from_path(path) # :nodoc:
|
||||||
unless Zip::RUNNING_ON_WINDOWS
|
return if Zip::RUNNING_ON_WINDOWS
|
||||||
stat = file_stat(path)
|
stat = file_stat(path)
|
||||||
@unix_uid = stat.uid
|
@unix_uid = stat.uid
|
||||||
@unix_gid = stat.gid
|
@unix_gid = stat.gid
|
||||||
@unix_perms = stat.mode & 07777
|
@unix_perms = stat.mode & 07777
|
||||||
end
|
end
|
||||||
end
|
|
||||||
|
|
||||||
def set_unix_permissions_on_path(dest_path)
|
def set_unix_permissions_on_path(dest_path)
|
||||||
# BUG: does not update timestamps into account
|
# BUG: does not update timestamps into account
|
||||||
|
|
|
@ -26,13 +26,12 @@ module Zip
|
||||||
tags = parse_tags(content)
|
tags = parse_tags(content)
|
||||||
|
|
||||||
tag1 = tags[1]
|
tag1 = tags[1]
|
||||||
if tag1
|
return unless tag1
|
||||||
ntfs_mtime, ntfs_atime, ntfs_ctime = tag1.unpack('Q<Q<Q<')
|
ntfs_mtime, ntfs_atime, ntfs_ctime = tag1.unpack('Q<Q<Q<')
|
||||||
ntfs_mtime && @mtime ||= from_ntfs_time(ntfs_mtime)
|
ntfs_mtime && @mtime ||= from_ntfs_time(ntfs_mtime)
|
||||||
ntfs_atime && @atime ||= from_ntfs_time(ntfs_atime)
|
ntfs_atime && @atime ||= from_ntfs_time(ntfs_atime)
|
||||||
ntfs_ctime && @ctime ||= from_ntfs_time(ntfs_ctime)
|
ntfs_ctime && @ctime ||= from_ntfs_time(ntfs_ctime)
|
||||||
end
|
end
|
||||||
end
|
|
||||||
|
|
||||||
def ==(other)
|
def ==(other)
|
||||||
@mtime == other.mtime &&
|
@mtime == other.mtime &&
|
||||||
|
|
|
@ -385,7 +385,7 @@ module Zip
|
||||||
|
|
||||||
def check_entry_exists(entryName, continue_on_exists_proc, procedureName)
|
def check_entry_exists(entryName, continue_on_exists_proc, procedureName)
|
||||||
continue_on_exists_proc ||= proc { Zip.continue_on_exists_proc }
|
continue_on_exists_proc ||= proc { Zip.continue_on_exists_proc }
|
||||||
if @entry_set.include?(entryName)
|
return unless @entry_set.include?(entryName)
|
||||||
if continue_on_exists_proc.call
|
if continue_on_exists_proc.call
|
||||||
remove get_entry(entryName)
|
remove get_entry(entryName)
|
||||||
else
|
else
|
||||||
|
@ -393,7 +393,6 @@ module Zip
|
||||||
procedureName + " failed. Entry #{entryName} already exists"
|
procedureName + " failed. Entry #{entryName} already exists"
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
|
||||||
|
|
||||||
def check_file(path)
|
def check_file(path)
|
||||||
raise Errno::ENOENT, path unless ::File.readable?(path)
|
raise Errno::ENOENT, path unless ::File.readable?(path)
|
||||||
|
|
|
@ -27,7 +27,7 @@ class ZipFileSplitTest < MiniTest::Test
|
||||||
def test_split
|
def test_split
|
||||||
result = ::Zip::File.split(TEST_ZIP.zip_name, 65_536, false)
|
result = ::Zip::File.split(TEST_ZIP.zip_name, 65_536, false)
|
||||||
|
|
||||||
unless result.nil?
|
return if result.nil?
|
||||||
Dir["#{TEST_ZIP.zip_name}.*"].sort.each_with_index do |zip_file_name, index|
|
Dir["#{TEST_ZIP.zip_name}.*"].sort.each_with_index do |zip_file_name, index|
|
||||||
File.open(zip_file_name, 'rb') do |zip_file|
|
File.open(zip_file_name, 'rb') do |zip_file|
|
||||||
zip_file.read([::Zip::File::SPLIT_SIGNATURE].pack('V').size) if index == 0
|
zip_file.read([::Zip::File::SPLIT_SIGNATURE].pack('V').size) if index == 0
|
||||||
|
@ -55,4 +55,3 @@ class ZipFileSplitTest < MiniTest::Test
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
|
||||||
|
|
Loading…
Reference in New Issue