fontist/excavate

View on GitHub

Showing 7 of 7 total issues

File cpio_old_format.rb has 352 lines of code (exceeds 250 allowed). Consider refactoring.
Open

require 'stringio'

module CPIO
  class ArchiveFormatError < IOError; end

Severity: Minor
Found in lib/excavate/extractors/cpio/cpio_old_format.rb - About 4 hrs to fix

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

      class Archive
        INVALID_MEMORY_MESSAGE =
          "invalid memory read at address=0x0000000000000000".freeze
    
        TYPES = { "cab" => Extractors::CabExtractor,
    Severity: Minor
    Found in lib/excavate/archive.rb - About 3 hrs to fix

      Method validate has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
      Open

        def validate
          raise "Invalid magic #{magic.inspect}" if magic != 0x070701
          raise "Invalid ino #{ino.inspect}" if ino < 0
          raise "Invalid mode #{mode.inspect}" if mode < 0
          raise "Invalid uid #{uid.inspect}" if uid < 0
      Severity: Minor
      Found in lib/excavate/extractors/cpio/cpio.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 each has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
      Open

        def each(&block)
          while true
            entry = read
            break if entry.nil?
            # The CPIO format has the end-of-stream marker as a file called "TRAILER!!!"
      Severity: Minor
      Found in lib/excavate/extractors/cpio/cpio.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 to_data has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
      Open

          def to_data
            Fields.collect do |(width,name)|
              raise ArchiveFormatError, "Expected header to have key #{name}" unless @attrs.has_key?(name)
              val = @attrs[name].respond_to?(:to_proc) ? @attrs[name].call : @attrs[name]
              raise ArchiveFormatError, "Header value for #{name} exceeds max length of #{FieldMaxValues[name]}" if val > FieldMaxValues[name]
      Severity: Minor
      Found in lib/excavate/extractors/cpio/cpio_old_format.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 verify_correct_read has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
      Open

        def verify_correct_read(entry)
          # Read and throw away the whole file if not read at all.
          entry.file.tap do |file|
            if file.nil? ||  file.remaining == 0
              # All OK! :)
      Severity: Minor
      Found in lib/excavate/extractors/cpio/cpio.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 extract_once has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
      Open

          def extract_once(archive, target)
            extension = normalized_extension(archive)
            extractor_class = TYPES[extension]
            unless extractor_class
              raise(UnknownArchiveError, "Could not unarchive `#{archive}`.")
      Severity: Minor
      Found in lib/excavate/archive.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

      Severity
      Category
      Status
      Source
      Language