Method prepare_options
has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring. Open
def prepare_options
prepared_options = {}
options.each do |k, v|
if oinfo_i = CoAP::OPTIONS_I[k]
onum, oname, defv, minmax, rep, _, encoder = *oinfo_i
- 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
has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring. Open
def self.parse(d)
# dpos keeps our current position in parsing d
b1, mcode, mid = d.unpack("CCn"); dpos = 4
toklen = b1 & 0xf
token = d.byteslice(dpos, toklen); dpos += toklen
- 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 initialize
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
def initialize(*args) # convenience: .new(tt?, mcode?, mid?, payload?, hash?)
if args.size < 6
h = {}
h = args.pop.dup if args.last.is_a? Hash
- 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_wire
has 28 lines of code (exceeds 25 allowed). Consider refactoring. Open
def to_wire
# check and encode option values
prepared_options = prepare_options
token = (prepared_options.delete(CoAP::TOKEN_ON) || [nil])[0] || ''
Method parse
has 27 lines of code (exceeds 25 allowed). Consider refactoring. Open
def self.parse(d)
# dpos keeps our current position in parsing d
b1, mcode, mid = d.unpack("CCn"); dpos = 4
toklen = b1 & 0xf
token = d.byteslice(dpos, toklen); dpos += toklen
Consider simplifying this complex logical expression. Open
if args.size < 6
h = {}
h = args.pop.dup if args.last.is_a? Hash
tt = h.delete(:tt) || args.shift
Method decode_options_and_put_together
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
def self.decode_options_and_put_together(b1, tt, mcode, mid, options, payload)
# check and decode option values
decoded_options = CoAP::DEFAULTING_OPTIONS.dup
options.each_pair do |k, v|
if oinfo = CoAP::OPTIONS[k]
- 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 decode_options_and_put_together
has 6 arguments (exceeds 4 allowed). Consider refactoring. Open
def self.decode_options_and_put_together(b1, tt, mcode, mid, options, payload)
Method to_wire
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def to_wire
# check and encode option values
prepared_options = prepare_options
token = (prepared_options.delete(CoAP::TOKEN_ON) || [nil])[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"