Showing 12 of 12 total issues
Method available?
has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring. Open
Open
def self.available?(buffer)
if buffer.size >= 1
raise StartOfFrameInvalid unless buffer.slice(0).unpack('C')[0] == FRAME_START
if buffer.size >= 3
payload_length = buffer.slice(1..2).unpack('S>')[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 pack_value
has 32 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
def pack_value(datatype, value, data)
case datatype
when :boolean
data += [to_boolean(value) ? 1 : 0].pack('C')
when :int8
Method parse_value
has 31 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
def self.parse_value(datatype, data)
case datatype
when :boolean
return data.slice!(0).unpack('C')[0] == 1
when :int8
Method array_elements
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
Open
def array_elements
@arguments.inject(0) { |sum, a| sum + (a.array ? a.value.is_a?(Array) ? a.value.size : 0 : 0) }
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
Avoid too many return
statements within this method. Open
Open
return data.slice!(0..7).unpack('q>')[0]
Avoid too many return
statements within this method. Open
Open
return length > 0 ? data.slice!(0..length - 1) : ''
Avoid too many return
statements within this method. Open
Open
return data.slice!(0..1).unpack('S>')[0]
Avoid too many return
statements within this method. Open
Open
return data.slice!(0).unpack('C')[0]
Avoid too many return
statements within this method. Open
Open
return data.slice!(0..7).unpack('Q>')[0]
Avoid too many return
statements within this method. Open
Open
return data.slice!(0..7).unpack('G')[0]
Avoid too many return
statements within this method. Open
Open
return data.slice!(0..3).unpack('L>')[0]
Avoid too many return
statements within this method. Open
Open
return data.slice!(0..3).unpack('g')[0]