Showing 17 of 23 total issues
Method client
has a Cognitive Complexity of 38 (exceeds 5 allowed). Consider refactoring. Open
def client(method, path, host = nil, port = nil, payload = nil, options = {}, observe_callback = nil)
# Set host and port only one time on multiple requests
host.nil? ? (host = @host unless @host.nil?) : @host = host
port.nil? ? (port = @port unless @port.nil?) : @port = port
- 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 client
has 56 lines of code (exceeds 25 allowed). Consider refactoring. Open
def client(method, path, host = nil, port = nil, payload = nil, options = {}, observe_callback = nil)
# Set host and port only one time on multiple requests
host.nil? ? (host = @host unless @host.nil?) : @host = host
port.nil? ? (port = @port unless @port.nil?) : @port = port
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 initialize
has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring. Open
def initialize(options = {})
@max_retransmit = options[:max_retransmit] || 4
@recv_timeout = options[:recv_timeout] || DEFAULT_RECV_TIMEOUT
@socket = options[:socket]
@force_ipv6 = !!options[:force_ipv6]
- 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 request
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
def request(message, host, port = CoAP::PORT)
retry_count = 0
retransmit = @retransmit && message.tt == :con
begin
- 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 client
has 7 arguments (exceeds 4 allowed). Consider refactoring. Open
def client(method, path, host = nil, port = nil, payload = nil, options = {}, observe_callback = nil)
Method observe
has 6 arguments (exceeds 4 allowed). Consider refactoring. Open
def observe(path, host, port, callback, payload = nil, options = {})
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 validate_arguments!
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def validate_arguments!(host, port, path, payload)
if host.nil? || host.empty?
fail ArgumentError, 'Argument «host» missing.'
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 observe
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def observe(message, callback, socket)
n = message.options[:observe]
callback.call(socket, message)
- 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 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"