jphastings/rubyzip

View on GitHub
lib/zip/file.rb

Summary

Maintainability
C
1 day
Test Coverage

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

    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 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 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 save_splited_part has 6 arguments (exceeds 4 allowed). Consider refactoring.
        Open

              def save_splited_part(zip_file, partial_zip_file_name, zip_file_size, szip_file_index, segment_size, segment_count)
        Severity: Minor
        Found in lib/zip/file.rb - About 45 mins to fix

          Method split has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
          Open

                def split(zip_file_name, segment_size = MAX_SEGMENT_SIZE, delete_zip_file = true, partial_zip_file_name = nil)
                  raise Error, "File #{zip_file_name} not found" unless ::File.exist?(zip_file_name)
                  raise Errno::ENOENT, zip_file_name unless ::File.readable?(zip_file_name)
                  zip_file_size = ::File.size(zip_file_name)
                  segment_size  = get_segment_size_for_split(segment_size)
          Severity: Minor
          Found in lib/zip/file.rb - About 45 mins 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

          There are no issues that match your filters.

          Category
          Status