rubyzip/rubyzip

View on GitHub

Showing 55 of 55 total issues

File entry.rb has 635 lines of code (exceeds 250 allowed). Consider refactoring.
Open

require 'pathname'

require_relative 'dirtyable'

module Zip
Severity: Major
Found in lib/zip/entry.rb - About 1 day to fix

    Class Entry has 65 methods (exceeds 20 allowed). Consider refactoring.
    Open

      class Entry
        include Dirtyable
    
        # Constant used to specify that the entry is stored (i.e., not compressed).
        STORED   = ::Zip::COMPRESSION_METHOD_STORE
    Severity: Major
    Found in lib/zip/entry.rb - About 1 day to fix

      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
      Severity: Minor
      Found in lib/zip/filesystem/file.rb - About 6 hrs to fix

        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 # :nodoc:
        Severity: Minor
        Found in lib/zip/file.rb - About 3 hrs to fix

          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
          Severity: Minor
          Found in lib/zip/ioextras/abstract_input_stream.rb - About 2 hrs to fix

          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 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
          Severity: Minor
          Found in lib/zip/ioextras/abstract_input_stream.rb - About 2 hrs to fix

          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

          File file.rb has 252 lines of code (exceeds 250 allowed). Consider refactoring.
          Open

          require 'forwardable'
          
          require_relative 'file_split'
          
          module Zip
          Severity: Minor
          Found in lib/zip/file.rb - About 2 hrs to fix

            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
            
            
            Severity: Minor
            Found in lib/zip/entry.rb - About 1 hr to fix

            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
            Severity: Minor
            Found in lib/zip/extra_field/universal_time.rb - About 1 hr to fix

            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,
            Severity: Minor
            Found in lib/zip/central_directory.rb - About 1 hr to fix

            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 # :nodoc:
                  zip64 = @extra['Zip64']
                  [
                    @header_signature,
                    @version, # version of encoding software
            Severity: Minor
            Found in lib/zip/entry.rb - About 1 hr to fix

            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
            Severity: Minor
            Found in lib/zip/entry.rb - About 1 hr to fix

            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
            Severity: Minor
            Found in lib/zip/central_directory.rb - About 1 hr to fix

            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:
                  @dirty = false # No changes at this point.
                  @local_header_offset = io.tell
            
                  static_sized_fields_buf = io.read(::Zip::LOCAL_ENTRY_STATIC_HEADER_LENGTH) || ''
            Severity: Minor
            Found in lib/zip/entry.rb - About 1 hr to fix

            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
            Severity: Minor
            Found in lib/zip/entry.rb - About 1 hr to fix

            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.
            Severity: Minor
            Found in lib/zip/file.rb - About 1 hr to fix

            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
            Severity: Minor
            Found in lib/zip/extra_field.rb - About 1 hr to fix

            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:
                  prep_cdir_zip64_extra
            
                  case @fstype
                  when ::Zip::FSTYPE_UNIX
            Severity: Minor
            Found in lib/zip/entry.rb - About 1 hr to fix

            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
            Severity: Minor
            Found in lib/zip/entry.rb - About 1 hr to fix

              Method read has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
              Open

                  def read(length = nil, outbuf = +'')
                    return (length.nil? || length.zero? ? '' : nil) if eof
              
                    while length.nil? || (@buffer.bytesize < length)
                      break if input_finished?
              Severity: Minor
              Found in lib/zip/inflater.rb - About 1 hr to fix

              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

              Severity
              Category
              Status
              Source
              Language