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
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,
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
- Read upRead up
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!!!"
- Read upRead up
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! :)
- Read upRead up
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]
- Read upRead up
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}`.")
- Read upRead up
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"