rubyzip/rubyzip

View on GitHub

Showing 55 of 55 total issues

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

require 'pathname'
module Zip
  class Entry
    STORED   = 0
    DEFLATED = 8
Severity: Major
Found in lib/zip/entry.rb - About 1 day to fix

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

      class Entry
        STORED   = 0
        DEFLATED = 8
        # Language encoding flag (EFS) bit
        EFS = 0b100000000000
    Severity: Major
    Found in lib/zip/entry.rb - About 1 day to fix

      File filesystem.rb has 463 lines of code (exceeds 250 allowed). Consider refactoring.
      Open

      require 'zip'
      
      module Zip
        # The ZipFileSystem API provides an API for accessing entries in
        # a zip archive that is similar to ruby's builtin File and Dir
      Severity: Minor
      Found in lib/zip/filesystem.rb - About 7 hrs to fix

        Class ZipFsFile has 47 methods (exceeds 20 allowed). Consider refactoring.
        Open

            class ZipFsFile
              attr_writer :dir
              # protected :dir
        
              class ZipFsStat
        Severity: Minor
        Found in lib/zip/filesystem.rb - About 6 hrs to fix

          Class File has 33 methods (exceeds 20 allowed). Consider refactoring.
          Open

            class File < CentralDirectory
              CREATE               = true
              SPLIT_SIGNATURE      = 0x08074b50
              ZIP64_EOCD_SIGNATURE = 0x06064b50
              MAX_SEGMENT_SIZE     = 3_221_225_472
          Severity: Minor
          Found in lib/zip/file.rb - About 4 hrs to fix

            Method prep_zip64_extra has a Cognitive Complexity of 23 (exceeds 5 allowed). Consider refactoring.
            Open

                def prep_zip64_extra(for_local_header) #:nodoc:all
                  return unless ::Zip.write_zip64_support
            
                  need_zip64 = @size >= 0xFFFFFFFF || @compressed_size >= 0xFFFFFFFF
                  need_zip64 ||= @local_header_offset >= 0xFFFFFFFF unless for_local_header
            Severity: Minor
            Found in lib/zip/entry.rb - About 3 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 302 lines of code (exceeds 250 allowed). Consider refactoring.
            Open

            module Zip
              # ZipFile is modeled after java.util.zip.ZipFile from the Java SDK.
              # The most important methods are those inherited from
              # ZipCentralDirectory for accessing information about the entries in
              # the archive and methods such as get_input_stream and
            Severity: Minor
            Found in lib/zip/file.rb - About 3 hrs to fix

              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

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

                    def read(number_of_bytes = nil, buf = '')
                      tbuf = if @output_buffer.bytesize > 0
                               if 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 merge has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
              Open

                  def merge(binstr)
                    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 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 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::DestinationFileExistsError,
                            "Destination '#{dest_path}' already exists"
                    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 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_given?
                      ::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 initialize has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
              Open

                  def initialize(path_or_io, create = false, buffer = false, options = {})
                    super()
                    options  = DEFAULT_OPTIONS.merge(options)
                    @name    = path_or_io.respond_to?(:path) ? path_or_io.path : path_or_io
                    @comment = ''
              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 save_splited_part has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
              Open

                    def save_splited_part(zip_file, partial_zip_file_name, zip_file_size, szip_file_index, segment_size, segment_count)
                      ssegment_size  = zip_file_size - zip_file.pos
                      ssegment_size  = segment_size if ssegment_size > segment_size
                      szip_file_name = "#{partial_zip_file_name}.#{format('%03d', szip_file_index)}"
                      ::File.open(szip_file_name, 'wb') do |szip_file|
              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 read_local_entry has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
              Open

                  def read_local_entry(io) #:nodoc:all
                    @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 put_next_entry has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
              Open

                  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
              
                    new_entry = if entry_name.kind_of?(Entry)
                                  entry_name
              Severity: Minor
              Found in lib/zip/output_stream.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 11 (exceeds 5 allowed). Consider refactoring.
              Open

                  def pack_c_dir_entry
                    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 open_buffer has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
              Open

                    def open_buffer(io, 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
              
              
              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 get_output_stream has 10 arguments (exceeds 4 allowed). Consider refactoring.
              Open

                  def get_output_stream(entry, permission_int = nil, comment = nil,
                                        extra = nil, compressed_size = nil, crc = nil,
                                        compression_method = nil, size = nil, time = nil,
                                        &a_proc)
              Severity: Major
              Found in lib/zip/file.rb - About 1 hr to fix
                Severity
                Category
                Status
                Source
                Language