Showing 842 of 1,379 total issues
Avoid deeply nested control flow statements. Open
Open
if endianness == :LITTLE_ENDIAN
buffer[lower_bound..upper_bound] = temp_array.pack(PACK_8_BIT_UINT_ARRAY).reverse
else
buffer[lower_bound..upper_bound] = temp_array.pack(PACK_8_BIT_UINT_ARRAY)
end
Avoid deeply nested control flow statements. Open
Open
if endianness == HOST_ENDIANNESS
packed = values.pack(PACK_NATIVE_64_BIT_INT_ARRAY)
else # endianness != HOST_ENDIANNESS
packed = values.pack(PACK_NATIVE_64_BIT_INT_ARRAY)
self.byte_swap_buffer!(packed, 8)
Method read_array
has 6 arguments (exceeds 4 allowed). Consider refactoring. Open
Open
def self.read_array(bit_offset, bit_size, data_type, array_size, buffer, endianness)
Avoid deeply nested control flow statements. Open
Open
if data_type == :INT
###########################################################
# Handle byte-aligned 8, 16, 32, and 64 bit :INT
###########################################################
Avoid deeply nested control flow statements. Open
Open
if old_upper_bound < lower_bound
# String was completely empty
if end_bytes > 0
# Preserve bytes at end of buffer
buffer << ("\000" * value.length)
Avoid deeply nested control flow statements. Open
Open
if value.length < byte_size
# Pad the requested size with zeros
temp = value.ljust(byte_size, "\000")
elsif value.length > byte_size
if overflow == :TRUNCATE
Avoid deeply nested control flow statements. Open
Open
if endianness == :BIG_ENDIAN
packed = values.pack(PACK_BIG_ENDIAN_16_BIT_UINT_ARRAY)
else # endianness == :LITTLE_ENDIAN
packed = values.pack(PACK_LITTLE_ENDIAN_16_BIT_UINT_ARRAY)
end
Avoid deeply nested control flow statements. Open
Open
if endianness == HOST_ENDIANNESS
value = buffer[lower_bound..upper_bound].unpack(PACK_NATIVE_16_BIT_INT_ARRAY)
else # endianness != HOST_ENDIANNESS
temp = self.byte_swap_buffer(buffer[lower_bound..upper_bound], 2)
value = temp.to_s.unpack(PACK_NATIVE_16_BIT_INT_ARRAY)
Avoid deeply nested control flow statements. Open
Open
if endianness == HOST_ENDIANNESS
value = buffer[lower_bound..upper_bound].unpack(PACK_NATIVE_32_BIT_INT_ARRAY)
else # endianness != HOST_ENDIANNESS
temp = self.byte_swap_buffer(buffer[lower_bound..upper_bound], 4)
value = temp.to_s.unpack(PACK_NATIVE_32_BIT_INT_ARRAY)
Avoid deeply nested control flow statements. Open
Open
if endianness == :BIG_ENDIAN
packed = values.pack(PACK_BIG_ENDIAN_32_BIT_UINT_ARRAY)
else # endianness == :LITTLE_ENDIAN
packed = values.pack(PACK_LITTLE_ENDIAN_32_BIT_UINT_ARRAY)
end
Avoid deeply nested control flow statements. Open
Open
if id
id = entry[(packet_name_length + 4)..-1]
@packet_ids << id
end
Avoid deeply nested control flow statements. Open
Open
if upper_bound > lower_bound
# Combine bytes into a FixNum
temp_data[1..temp_upper].each_byte do |temp_value|
temp = temp << 8
temp = temp + temp_value
Avoid deeply nested control flow statements. Open
Open
if endianness == HOST_ENDIANNESS
packed = values.pack(PACK_NATIVE_64_BIT_UINT_ARRAY)
else # endianness != HOST_ENDIANNESS
packed = values.pack(PACK_NATIVE_64_BIT_UINT_ARRAY)
self.byte_swap_buffer!(packed, 8)
Avoid deeply nested control flow statements. Open
Open
if value
item.default = value
else
raise "Unknown DEFAULT #{@defaults[index]} for item #{item.name}. Valid states are #{item.states.keys.join(', ')}."
end
Avoid deeply nested control flow statements. Open
Open
if data_type == :INT
###########################################################
# Handle byte-aligned 8, 16, 32, and 64 bit :INT
###########################################################
Avoid deeply nested control flow statements. Open
Open
if endianness == :LITTLE_ENDIAN
# Bitoffset always refers to the most significant bit of a bitfield
num_bytes = (((bit_offset % 8) + bit_size - 1) / 8) + 1
upper_bound = bit_offset / 8
lower_bound = upper_bound - num_bytes + 1
Method initialize
has 6 arguments (exceeds 4 allowed). Consider refactoring. Open
Open
def initialize(hostname, write_port, read_port, write_timeout, read_timeout, connect_timeout = 5.0)
Avoid deeply nested control flow statements. Open
Open
if endianness == HOST_ENDIANNESS
packed = values.pack(PACK_NATIVE_16_BIT_INT_ARRAY)
else # endianness != HOST_ENDIANNESS
packed = values.pack(PACK_NATIVE_16_BIT_INT_ARRAY)
self.byte_swap_buffer!(packed, 2)
Avoid deeply nested control flow statements. Open
Open
if endianness == HOST_ENDIANNESS
value = buffer[lower_bound..upper_bound].unpack(PACK_NATIVE_64_BIT_UINT_ARRAY)
else # endianness != HOST_ENDIANNESS
temp = self.byte_swap_buffer(buffer[lower_bound..upper_bound], 8)
value = temp.to_s.unpack(PACK_NATIVE_64_BIT_UINT_ARRAY)
Avoid deeply nested control flow statements. Open
Open
if endianness == :BIG_ENDIAN
value = buffer[lower_bound..upper_bound].unpack(PACK_BIG_ENDIAN_16_BIT_UINT_ARRAY)
else # endianness == :LITTLE_ENDIAN
value = buffer[lower_bound..upper_bound].unpack(PACK_LITTLE_ENDIAN_16_BIT_UINT_ARRAY)
end