File io.rb
has 2398 lines of code (exceeds 250 allowed). Consider refactoring. Open
class IO
include Enumerable
def self.fnmatch(pattern, path, flags)
Rubinius.primitive :io_fnmatch
Class IO
has 122 methods (exceeds 20 allowed). Consider refactoring. Open
class IO
include Enumerable
def self.fnmatch(pattern, path, flags)
Rubinius.primitive :io_fnmatch
Method popen
has a Cognitive Complexity of 57 (exceeds 5 allowed). Consider refactoring. Open
def self.popen(*args)
if env = Rubinius::Type.try_convert(args.first, Hash, :to_hash)
args.shift
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 normalize_options
has a Cognitive Complexity of 53 (exceeds 5 allowed). Consider refactoring. Open
def self.normalize_options(mode, options)
mode = nil if undefined.equal?(mode)
autoclose = true
encoding_options = {}
- 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
Class FileDescriptor
has 48 methods (exceeds 20 allowed). Consider refactoring. Open
class FileDescriptor
class RIOStream
def self.close(io, allow_exception)
Rubinius.primitive :rio_close
raise PrimitiveFailure, "IO::FileDescriptor::RIOStream.close primitive failed"
Method reopen
has a Cognitive Complexity of 29 (exceeds 5 allowed). Consider refactoring. Open
def reopen(other, mode=undefined)
if other.respond_to?(:to_io)
flush
if other.kind_of? IO
- 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 strip_bom
has a Cognitive Complexity of 29 (exceeds 5 allowed). Consider refactoring. Open
def strip_bom
return unless File::Stat.fstat(descriptor).file?
case b1 = getbyte
when 0x00
- 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 puts
has a Cognitive Complexity of 29 (exceeds 5 allowed). Consider refactoring. Open
def puts(*args)
if args.empty?
write DEFAULT_RECORD_SEPARATOR
else
args.each do |arg|
- 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 popen
has 96 lines of code (exceeds 25 allowed). Consider refactoring. Open
def self.popen(*args)
if env = Rubinius::Type.try_convert(args.first, Hash, :to_hash)
args.shift
end
Method validate_and_convert_argument
has a Cognitive Complexity of 26 (exceeds 5 allowed). Consider refactoring. Open
def self.validate_and_convert_argument(objects)
if objects
raise TypeError, "Argument must be an Array" unless objects.respond_to?(:to_ary)
objects =
objects.to_ary.map do |obj|
- 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 set_encoding
has a Cognitive Complexity of 25 (exceeds 5 allowed). Consider refactoring. Open
def set_encoding(external, internal=nil, options=undefined)
case external
when Encoding
@external = external
when String
- 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 select
has a Cognitive Complexity of 24 (exceeds 5 allowed). Consider refactoring. Open
def self.select(readables, writables, errorables, timeout)
read_set, highest_read_fd = readables.nil? ? [nil, nil] : fd_set_from_array(readables)
write_set, highest_write_fd = writables.nil? ? [nil, nil] : fd_set_from_array(writables)
error_set, highest_err_fd = errorables.nil? ? [nil, nil] : fd_set_from_array(errorables)
max_fd = [highest_read_fd, highest_write_fd, highest_err_fd].compact.max || -1
- 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 write
has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring. Open
def write(str)
buf_size = str.bytesize
left = buf_size
buffer = FFI::MemoryPointer.new(left)
- 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 run
has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring. Open
def run
@from.ensure_open_and_readable if @from.kind_of? IO
@to.ensure_open_and_writable if @to.kind_of? IO
if @offset
- 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 read
has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring. Open
def self.read(name, length_or_options=undefined, offset=0, options=nil)
offset = 0 if offset.nil?
name = Rubinius::Type.coerce_to_path name
mode = "r"
- 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 foreach
has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring. Open
def self.foreach(name, separator=undefined, limit=undefined, options=undefined)
return to_enum(:foreach, name, separator, limit, options) unless block_given?
name = Rubinius::Type.coerce_to_path 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 normalize_options
has 66 lines of code (exceeds 25 allowed). Consider refactoring. Open
def self.normalize_options(mode, options)
mode = nil if undefined.equal?(mode)
autoclose = true
encoding_options = {}
Method foreach
has 57 lines of code (exceeds 25 allowed). Consider refactoring. Open
def self.foreach(name, separator=undefined, limit=undefined, options=undefined)
return to_enum(:foreach, name, separator, limit, options) unless block_given?
name = Rubinius::Type.coerce_to_path name
Method each_line
has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring. Open
def each_line(sep_or_limit=$/, limit=nil, &block)
if limit
limit = Rubinius::Type.coerce_to limit, Integer, :to_int
sep = sep_or_limit ? StringValue(sep_or_limit) : nil
raise ArgumentError, "invalid limit: 0 for each_line" if limit.zero?
- 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 16 (exceeds 5 allowed). Consider refactoring. Open
def each(sep_or_limit=$/, limit=nil, &block)
return to_enum(:each, sep_or_limit, limit) unless block_given?
ensure_open_and_readable
- 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 readpartial
has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring. Open
def readpartial(size, buffer=nil)
raise ArgumentError, 'negative string size' unless size >= 0
ensure_open
if buffer
- 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 strip_bom
has 52 lines of code (exceeds 25 allowed). Consider refactoring. Open
def strip_bom
return unless File::Stat.fstat(descriptor).file?
case b1 = getbyte
when 0x00
Method set_encoding
has 49 lines of code (exceeds 25 allowed). Consider refactoring. Open
def set_encoding(external, internal=nil, options=undefined)
case external
when Encoding
@external = external
when String
Method read
has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring. Open
def read(length=nil, buffer=nil)
ensure_open_and_readable
buffer = StringValue(buffer) if buffer
unless length
- 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 parse_mode
has 44 lines of code (exceeds 25 allowed). Consider refactoring. Open
def self.parse_mode(mode)
return mode if Rubinius::Type.object_kind_of? mode, Integer
mode = StringValue(mode)
Method initialize
has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring. Open
def initialize(fd, mode=undefined, options=undefined)
if block_given?
warn 'IO::new() does not take block; use IO::open() instead'
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 setup
has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring. Open
def self.setup(io, fd, mode=nil, sync=false)
cur_mode = FileDescriptor.get_flags(fd)
Errno.handle if cur_mode < 0
cur_mode &= ACCMODE
- 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 read_nonblock
has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring. Open
def read_nonblock(size, buffer=nil, exception: true)
raise ArgumentError, "illegal read size" if size < 0
ensure_open
buffer = StringValue buffer if buffer
- 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 read
has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring. Open
def read(length, output_string=nil)
length ||= FileDescriptor.pagesize
while true
ensure_open
- 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 read_to_separator_with_limit
has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring. Open
def read_to_separator_with_limit(&block)
str = @io.get_empty_8bit_buffer
buffer = @io.get_empty_8bit_buffer
separator_size = @separator.bytesize
- 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 read
has 38 lines of code (exceeds 25 allowed). Consider refactoring. Open
def self.read(name, length_or_options=undefined, offset=0, options=nil)
offset = 0 if offset.nil?
name = Rubinius::Type.coerce_to_path name
mode = "r"
Method write
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
def self.write(file, string, *args)
if args.size > 2
raise ArgumentError, "wrong number of arguments (#{args.size + 2} for 2..3)"
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 reopen
has 35 lines of code (exceeds 25 allowed). Consider refactoring. Open
def reopen(other, mode=undefined)
if other.respond_to?(:to_io)
flush
if other.kind_of? IO
Method readpartial
has 32 lines of code (exceeds 25 allowed). Consider refactoring. Open
def readpartial(size, buffer=nil)
raise ArgumentError, 'negative string size' unless size >= 0
ensure_open
if buffer
Method read
has 32 lines of code (exceeds 25 allowed). Consider refactoring. Open
def read(length, output_string=nil)
length ||= FileDescriptor.pagesize
# Preferentially read from the buffer and then from the underlying
# FileDescriptor.
Method read_into_storage
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
def read_into_storage(count, storage)
while true
bytes_read = FFI::Platform::POSIX.read(descriptor, storage, count)
if FFI.call_failed?(bytes_read)
- 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 write
has 31 lines of code (exceeds 25 allowed). Consider refactoring. Open
def write(str)
buf_size = str.bytesize
left = buf_size
buffer = FFI::MemoryPointer.new(left)
Method initialize
has 31 lines of code (exceeds 25 allowed). Consider refactoring. Open
def initialize(fd, mode=undefined, options=undefined)
if block_given?
warn 'IO::new() does not take block; use IO::open() instead'
end
Method run
has 29 lines of code (exceeds 25 allowed). Consider refactoring. Open
def run
@from.ensure_open_and_readable if @from.kind_of? IO
@to.ensure_open_and_writable if @to.kind_of? IO
if @offset
Method read_to_separator_with_limit
has 28 lines of code (exceeds 25 allowed). Consider refactoring. Open
def read_to_separator_with_limit(&block)
str = @io.get_empty_8bit_buffer
buffer = @io.get_empty_8bit_buffer
separator_size = @separator.bytesize
Method puts
has 28 lines of code (exceeds 25 allowed). Consider refactoring. Open
def puts(*args)
if args.empty?
write DEFAULT_RECORD_SEPARATOR
else
args.each do |arg|
Method fd_set_from_array
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
def self.fd_set_from_array(array)
highest = -1
fd_set = FDSet.new
fd_set.zero
- 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 read
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
def read(length, output_string=nil)
length ||= FileDescriptor.pagesize
# Preferentially read from the buffer and then from the underlying
# FileDescriptor.
- 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 advise
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
def advise(advice, offset = 0, len = 0)
raise IOError, "stream is closed" if closed?
raise TypeError, "advice must be a Symbol" unless advice.kind_of?(Symbol)
if offset.kind_of?(Bignum) || len.kind_of?(Bignum)
- 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 select
has 27 lines of code (exceeds 25 allowed). Consider refactoring. Open
def self.select(readables, writables, errorables, timeout)
read_set, highest_read_fd = readables.nil? ? [nil, nil] : fd_set_from_array(readables)
write_set, highest_write_fd = writables.nil? ? [nil, nil] : fd_set_from_array(writables)
error_set, highest_err_fd = errorables.nil? ? [nil, nil] : fd_set_from_array(errorables)
max_fd = [highest_read_fd, highest_write_fd, highest_err_fd].compact.max || -1
Method advise
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
def advise(advice, offset = 0, len = 0)
raise IOError, "stream is closed" if closed?
raise TypeError, "advice must be a Symbol" unless advice.kind_of?(Symbol)
if offset.kind_of?(Bignum) || len.kind_of?(Bignum)
Method read_to_separator
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
def read_to_separator(&block)
str = @io.get_empty_8bit_buffer
buffer = @io.get_empty_8bit_buffer
separator_size = @separator.bytesize
- 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 write
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
def write(data)
data = String data
return 0 if data.bytesize == 0
ensure_open_and_writable
- 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 reopen_path
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
def reopen_path(path, mode)
current_fd = @descriptor
other_fd = FileDescriptor.open_with_cloexec(path, mode, 0666)
Errno.handle("could not reopen path \"#{path}\"") if other_fd < 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 collect_set_fds
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
def self.collect_set_fds(array, fd_set)
return [] unless fd_set
array.map do |io|
key, io = if io.is_a?(Array)
[io[0], io[1]]
- 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 binwrite
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def self.binwrite(file, string, *args)
offset, opts = args
opts ||= {}
if offset.is_a?(Hash)
offset, opts = nil, offset
- 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 pipe
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def self.pipe(external=nil, internal=nil, options=nil)
# The use of #allocate is to make sure we create an IO obj. Would be so much
# cleaner to just do a PipeIO class as a subclass, but that would not be
# backward compatible. <sigh>
fd0, fd1 = FIFOFileDescriptor.connect_pipe_fds
- 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 read_if_available
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def read_if_available(bytes)
return "" if bytes.zero?
buffer, bytes = @fd.read_only_buffer(bytes)
events = IO::Select.readable_events(descriptor)
- 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 ioctl
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def ioctl(command, arg=0)
ensure_open
if !arg
real_arg = 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 8 (exceeds 5 allowed). Consider refactoring. Open
def each(&block)
if @separator
if @separator.empty?
@separator = "\n\n"
@skip = "\n"
- 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 new_pipe
has 6 arguments (exceeds 4 allowed). Consider refactoring. Open
def new_pipe(fd, external, internal, options, mode, do_encoding=false)
Method read_to_char_boundary
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def read_to_char_boundary(io, str, buffer)
str.force_encoding(io.external_encoding || Encoding.default_external)
return [IO.read_encode(io, str, @encoding_options), 0] if str.valid_encoding?
peek_ahead = 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 __finalize__
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def __finalize__
return if @descriptor.nil? || @descriptor == -1
fd = @descriptor
- 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 close
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def close
ensure_open
fd = @descriptor
if fd != -1
- 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 shutdown
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def shutdown(how)
ensure_open
fd = descriptor
if how != IO::SHUT_RD && how != IO::SHUT_WR && how != IO::SHUT_RDWR
- 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
Avoid too many return
statements within this method. Open
return "UTF-16BE"
Avoid too many return
statements within this method. Open
return (nil || buffer)
Avoid too many return
statements within this method. Open
return "UTF-8"
Avoid too many return
statements within this method. Open
return buffer
Avoid too many return
statements within this method. Open
return ret
Method to_io
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def to_io(obj, mode)
if obj.kind_of? IO
flag = true
io = obj
else
- 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 select
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def self.select(readables=nil, writables=nil, errorables=nil, timeout=nil)
if timeout
unless Rubinius::Type.object_kind_of? timeout, Numeric
raise TypeError, "Timeout must be numeric"
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 parse_mode
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def self.parse_mode(mode)
return mode if Rubinius::Type.object_kind_of? mode, Integer
mode = StringValue(mode)
- 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 read_encode
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def self.read_encode(io, str, encoding_options)
internal = io.internal_encoding
external = io.external_encoding || Encoding.default_external
if external.equal? Encoding::ASCII_8BIT
- 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
Similar blocks of code found in 2 locations. Consider refactoring. Open
case mode[1]
when ?+
ret &= ~(RDONLY | WRONLY)
ret |= RDWR
when ?b
- Read upRead up
Duplicated Code
Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:
Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.
When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).
Tuning
This issue has a mass of 45.
We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.
The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.
If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.
See codeclimate-duplication
's documentation for more information about tuning the mass threshold in your .codeclimate.yml
.
Refactorings
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
Similar blocks of code found in 2 locations. Consider refactoring. Open
case mode[2]
when ?+
ret &= ~(RDONLY | WRONLY)
ret |= RDWR
when ?b
- Read upRead up
Duplicated Code
Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:
Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.
When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).
Tuning
This issue has a mass of 45.
We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.
The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.
If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.
See codeclimate-duplication
's documentation for more information about tuning the mass threshold in your .codeclimate.yml
.
Refactorings
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
Similar blocks of code found in 2 locations. Consider refactoring. Open
def self.timer_add(time1, time2, result)
result[:tv_sec] = time1[:tv_sec] + time2[:tv_sec]
result[:tv_usec] = time1[:tv_usec] + time2[:tv_usec]
if result[:tv_usec] >= 1_000_000
- Read upRead up
Duplicated Code
Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:
Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.
When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).
Tuning
This issue has a mass of 40.
We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.
The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.
If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.
See codeclimate-duplication
's documentation for more information about tuning the mass threshold in your .codeclimate.yml
.
Refactorings
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
Similar blocks of code found in 2 locations. Consider refactoring. Open
def self.timer_sub(time1, time2, result)
result[:tv_sec] = time1[:tv_sec] - time2[:tv_sec]
result[:tv_usec] = time1[:tv_usec] - time2[:tv_usec]
if result[:tv_usec] < 0
- Read upRead up
Duplicated Code
Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:
Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.
When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).
Tuning
This issue has a mass of 40.
We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.
The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.
If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.
See codeclimate-duplication
's documentation for more information about tuning the mass threshold in your .codeclimate.yml
.
Refactorings
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76