jphastings/rubyzip

View on GitHub
lib/zip/entry.rb

Summary

Maintainability
F
4 days
Test Coverage

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

      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

      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 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 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 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 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

          Method create_symlink has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
          Open

              def create_symlink(dest_path)
                stat = nil
                begin
                  stat = ::File.lstat(dest_path)
                rescue Errno::ENOENT
          Severity: Minor
          Found in lib/zip/entry.rb - About 55 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

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

              def gather_fileinfo_from_srcpath(src_path) # :nodoc:
                stat   = file_stat(src_path)
                @ftype = case stat.ftype
                         when 'file'
                           if name_is_directory?
          Severity: Minor
          Found in lib/zip/entry.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

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

              def initialize(*args)
                name = args[1] || ''
                check_name(name)
          
                set_default_vars_values
          Severity: Minor
          Found in lib/zip/entry.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

          Method pack_local_entry has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
          Open

              def pack_local_entry
                zip64 = @extra['Zip64']
                [::Zip::LOCAL_ENTRY_SIGNATURE,
                 @version_needed_to_extract, # version needed to extract
                 @gp_flags, # @gp_flags                  ,
          Severity: Minor
          Found in lib/zip/entry.rb - About 35 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

          Method create_directory has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
          Open

              def create_directory(dest_path)
                return if ::File.directory?(dest_path)
                if ::File.exist?(dest_path)
                  if block_given? && yield(self, dest_path)
                    ::FileUtils::rm_f dest_path
          Severity: Minor
          Found in lib/zip/entry.rb - About 25 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