rubyzip/rubyzip

View on GitHub

Showing 53 of 55 total issues

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

require 'pathname'
module Zip
  class Entry
    STORED   = ::Zip::COMPRESSION_METHOD_STORE
    DEFLATED = ::Zip::COMPRESSION_METHOD_DEFLATE
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   = ::Zip::COMPRESSION_METHOD_STORE
        DEFLATED = ::Zip::COMPRESSION_METHOD_DEFLATE
    
        # Language encoding flag (EFS) bit
    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

        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

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

          class File < CentralDirectory
            extend FileSplit
        
            IO_METHODS = [:tell, :seek, :read, :eof, :close].freeze
        
        
        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

          Method unpack_e_o_c_d has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
          Open

              def unpack_e_o_c_d(buffer) #:nodoc:
                index = buffer.rindex([END_OF_CDS].pack('V'))
                raise Error, 'Zip end of central directory signature not found' unless index
          
                buf = buffer.slice(index, buffer.size)
          Severity: Minor
          Found in lib/zip/central_directory.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 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 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 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 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_RESTORE_OPTIONS
                           .merge(compression_level: ::Zip.default_compression)
                           .merge(options)
          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_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 initialize has 32 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              def initialize(path_or_io, create: false, buffer: false, **options)
                super()
                options  = DEFAULT_RESTORE_OPTIONS
                           .merge(compression_level: ::Zip.default_compression)
                           .merge(options)
          Severity: Minor
          Found in lib/zip/file.rb - About 1 hr to fix

            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 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_zip64_extra(false)
                  case @fstype
                  when ::Zip::FSTYPE_UNIX
                    ft = case @ftype
            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 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 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 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 set_ftype_from_c_dir_entry has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
              Open

                  def set_ftype_from_c_dir_entry
                    @ftype = case @fstype
                             when ::Zip::FSTYPE_UNIX
                               @unix_perms = (@external_file_attributes >> 16) & 0o7777
                               case (@external_file_attributes >> 28)
              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

              Severity
              Category
              Status
              Source
              Language