Class File
has 26 methods (exceeds 20 allowed). Consider refactoring. Open
class File
extend Forwardable
extend FileSplit
IO_METHODS = [:tell, :seek, :read, :eof, :close].freeze # :nodoc:
Method initialize_cdir
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
def initialize_cdir(path_or_io, buffer: false)
@cdir = ::Zip::CentralDirectory.new
if ::File.size?(@name.to_s)
# There is a file, which exists, that is associated with this zip.
- 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 open_buffer
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
def open_buffer(io = ::StringIO.new, create: false, **options)
unless IO_METHODS.map { |method| io.respond_to?(method) }.all? || io.kind_of?(String)
raise 'Zip::File.open_buffer expects a String or IO-like argument' \
"(responds to #{IO_METHODS.join(', ')}). Found: #{io.class}"
end
- 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 on_success_replace
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def on_success_replace
dirname, basename = ::File.split(name)
::Dir::Tmpname.create(basename, dirname) do |tmp_filename|
if yield tmp_filename
::File.rename(tmp_filename, 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"