Showing 54 of 54 total issues
File entry.rb
has 632 lines of code (exceeds 250 allowed). Consider refactoring. Open
require 'pathname'
require_relative 'dirtyable'
module Zip
Class Entry
has 64 methods (exceeds 20 allowed). Consider refactoring. Open
class Entry
include Dirtyable
STORED = ::Zip::COMPRESSION_METHOD_STORE
DEFLATED = ::Zip::COMPRESSION_METHOD_DEFLATE
Class File
has 47 methods (exceeds 20 allowed). Consider refactoring. Open
class File # :nodoc:all
attr_writer :dir
def initialize(mapped_zip)
@mapped_zip = mapped_zip
Class File
has 26 methods (exceeds 20 allowed). Consider refactoring. Open
class File
extend Forwardable
extend FileSplit
IO_METHODS = [:tell, :seek, :read, :eof, :close].freeze
Method gets
has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring. Open
def gets(a_sep_string = $INPUT_RECORD_SEPARATOR, number_of_bytes = nil)
@lineno = @lineno.next
if number_of_bytes.respond_to?(:to_int)
number_of_bytes = number_of_bytes.to_int
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Method read
has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring. Open
def read(number_of_bytes = nil, buf = +'')
tbuf = if @output_buffer.bytesize > 0
if number_of_bytes && number_of_bytes <= @output_buffer.bytesize
@output_buffer.slice!(0, number_of_bytes)
else
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Method create_file
has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring. Open
def create_file(dest_path, _continue_on_exists_proc = proc { Zip.continue_on_exists_proc })
if ::File.exist?(dest_path) && !yield(self, dest_path)
raise ::Zip::DestinationExistsError, dest_path
end
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Method merge
has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring. Open
def merge(binstr)
return if binstr.empty?
size, content = initial_parse(binstr)
return if !size || size <= 0
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Method unpack_e_o_c_d
has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring. Open
def unpack_e_o_c_d(buffer) # :nodoc:
_, # END_OF_CD_SIG. We know we have this at this point.
num_disk,
num_disk_cdir,
num_cdir_disk,
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Method read_central_directory_entries
has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring. Open
def read_central_directory_entries(io) # :nodoc:
# `StringIO` doesn't raise `EINVAL` if you seek beyond the current end,
# so we need to catch that *and* query `io#eof?` here.
eof = false
begin
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Method pack_c_dir_entry
has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring. Open
def pack_c_dir_entry
zip64 = @extra['Zip64']
[
@header_signature,
@version, # version of encoding software
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Method get_input_stream
has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring. Open
def get_input_stream(&block)
if ftype == :directory
yield ::Zip::NullInputStream if block
::Zip::NullInputStream
elsif @filepath
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Method read_local_entry
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
def read_local_entry(io) # :nodoc:all
@dirty = false # No changes at this point.
@local_header_offset = io.tell
static_sized_fields_buf = io.read(::Zip::LOCAL_ENTRY_STATIC_HEADER_LENGTH) || ''
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Method prep_cdir_zip64_extra
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
def prep_cdir_zip64_extra
return unless ::Zip.write_zip64_support
if (@size && @size >= 0xFFFFFFFF) || @compressed_size >= 0xFFFFFFFF ||
@local_header_offset >= 0xFFFFFFFF
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Method merge
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
def merge(binstr, local: false)
return if binstr.empty?
i = 0
while i < binstr.bytesize
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Method write_c_dir_entry
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
def write_c_dir_entry(io) # :nodoc:all
prep_cdir_zip64_extra
case @fstype
when ::Zip::FSTYPE_UNIX
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Method initialize_cdir
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
def initialize_cdir(path_or_io, buffer: false)
@cdir = ::Zip::CentralDirectory.new
if ::File.size?(@name.to_s)
# There is a file, which exists, that is associated with this zip.
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Method get_input_stream
has 29 lines of code (exceeds 25 allowed). Consider refactoring. Open
def get_input_stream(&block)
if ftype == :directory
yield ::Zip::NullInputStream if block
::Zip::NullInputStream
elsif @filepath
Method open_buffer
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
def open_buffer(io = ::StringIO.new, create: false, **options)
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}"
end
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Method read_eocds
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
def read_eocds(io) # :nodoc:
base_location, data = eocd_data(io)
eocd_location = data.rindex([END_OF_CD_SIG].pack('V'))
raise Error, 'Zip end of central directory signature not found' unless eocd_location
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"