rubyzip/rubyzip

View on GitHub

Showing 54 of 54 total issues

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

    def self.find(path, zip_file_pattern = /\.zip$/i)
      Find.find(path) do |filename|
        yield(filename)
        next unless zip_file_pattern.match(filename) && File.file?(filename)

Severity: Minor
Found in samples/zipfind.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 read has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

    def read(length = nil, outbuf = +'')
      return (length.nil? || length.zero? ? '' : nil) if eof

      if length.nil? || (@read_so_far + length) > decompressed_size
        length = decompressed_size - @read_so_far
Severity: Minor
Found in lib/zip/pass_thru_decompressor.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

Avoid too many return statements within this method.
Open

      return if times[0].nil?
Severity: Major
Found in lib/zip/extra_field/universal_time.rb - About 30 mins to fix

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

        def extract(entry_path = @name, destination_directory: '.', &block)
          dest_dir = ::File.absolute_path(destination_directory || '.')
          extract_path = ::File.absolute_path(::File.join(dest_dir, entry_path))
    
          unless extract_path.start_with?(dest_dir)
    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

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

        def prep_local_zip64_extra
          return unless ::Zip.write_zip64_support
          return if (!zip64? && @size && @size < 0xFFFFFFFF) || !file?
    
          # Might not know size here, so need ZIP64 just in case.
    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

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

        def glob(pattern, flags = ::File::FNM_PATHNAME | ::File::FNM_DOTMATCH | ::File::FNM_EXTGLOB)
          entries.filter_map do |entry|
            next nil unless ::File.fnmatch(pattern, entry.name.chomp('/'), flags)
    
            yield(entry) if block_given?
    Severity: Minor
    Found in lib/zip/entry_set.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

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

      def write_entries(entries, path, zipfile)
        entries.each do |e|
          zipfile_path = path == '' ? e : File.join(path, e)
          disk_file_path = File.join(@input_dir, zipfile_path)
    
    
    Severity: Minor
    Found in samples/example_recursive.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

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

        def initialize(file_name, stream: false, encrypter: nil)
          super()
          @file_name = file_name
          @output_stream = if stream
                             iostream = Zip::RUNNING_ON_WINDOWS ? @file_name : @file_name.dup
    Severity: Minor
    Found in lib/zip/output_stream.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

    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)
            raise ::Zip::DestinationExistsError, dest_path unless block_given? && yield(self, 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

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

        def parse(original_size, compressed_size, relative_header_offset = nil, disk_start_number = nil)
          @original_size = extract(8, 'Q<') if original_size == 0xFFFFFFFF
          @compressed_size = extract(8, 'Q<') if compressed_size == 0xFFFFFFFF
          if relative_header_offset && relative_header_offset == 0xFFFFFFFF
            @relative_header_offset = extract(8, 'Q<')
    Severity: Minor
    Found in lib/zip/extra_field/zip64.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

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

        def pack_for_c_dir
          # reserved 0 and tag 1
          s = [0, 1].pack('Vv')
    
          tag1 = (+'').force_encoding(Encoding::BINARY)
    Severity: Minor
    Found in lib/zip/extra_field/ntfs.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

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

        def time=(value, component: :mtime)
          @dirty = true
          unless @extra.member?('UniversalTime') || @extra.member?('NTFS')
            @extra.create('UniversalTime')
          end
    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

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

        def pack_for_local
          s = [@flag].pack('C')
          s << [@mtime.to_i].pack('l<') unless @flag & MTIME_MASK == 0
          s << [@atime.to_i].pack('l<') unless @flag & ATIME_MASK == 0
          s << [@ctime.to_i].pack('l<') unless @flag & CTIME_MASK == 0
    Severity: Minor
    Found in lib/zip/extra_field/universal_time.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

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

        def write_e_o_c_d(io, offset, cdir_size) # :nodoc:
          tmp = [
            END_OF_CD_SIG,
            0, # @numberOfThisDisk
            0, # @numberOfDiskWithStartOfCDir
    Severity: Minor
    Found in lib/zip/central_directory.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

    Severity
    Category
    Status
    Source
    Language