jphastings/rubyzip

View on GitHub

Showing 44 of 44 total issues

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

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

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

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

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

      require 'zip'
      
      module Zip
      
        # The ZipFileSystem API provides an API for accessing entries in 
      Severity: Minor
      Found in lib/zip/filesystem.rb - About 6 hrs to fix

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

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

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

            class File < CentralDirectory
          
              CREATE               = 1
              SPLIT_SIGNATURE      = 0x08074b50
              ZIP64_EOCD_SIGNATURE = 0x06064b50
          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
                  unless for_local_header
                    need_zip64 ||= @local_header_offset >= 0xFFFFFFFF
            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 296 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 read has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
              Open

                    def read(number_of_bytes = nil, buf = '')
                      @decompressor.password = @password if !@password.nil? and @decompressor.respond_to? :password=
                      tbuf = if @output_buffer.bytesize > 0
                               if number_of_bytes <= @output_buffer.bytesize
                                 @output_buffer.slice!(0, number_of_bytes)
              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 = $/, 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_local_entry has a Cognitive Complexity of 17 (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 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
                      id  = binstr[i, 2]
              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 read_local_entry has 42 lines of code (exceeds 25 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

                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 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}.#{'%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 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
                      if entry_name.kind_of?(Entry)
                        new_entry = entry_name
                      else
                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 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,  &aProc)
                Severity: Major
                Found in lib/zip/file.rb - About 1 hr to fix

                  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 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 get_input_stream has 28 lines of code (exceeds 25 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

                    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) & 07777
                                     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