File rmcp.py
has 508 lines of code (exceeds 250 allowed). Consider refactoring. Open
# Copyright (c) 2018 Kontron Europe GmbH
#
# This library is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public
# License as published by the Free Software Foundation; either
Function _send_and_receive
has a Cognitive Complexity of 25 (exceeds 5 allowed). Consider refactoring. Open
def _send_and_receive(self, target, lun, netfn, cmdid, payload):
"""Send and receive data using RMCP interface.
target:
lun:
- 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
Function unpack
has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring. Open
def unpack(self, pdu):
auth_type = array('B', pdu)[0]
if auth_type != 0:
header_len = struct.calcsize(self.HEADER_FORMAT_AUTH)
- 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
Function pack
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
def pack(self, sdu):
if sdu is not None:
data_len = len(sdu)
else:
data_len = 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
Avoid deeply nested control flow statements. Open
if not rx_data:
# the forwarded reply is expected in the next packet
# so we do not increment the retry counter as
# it's not really a retry
continue
Function _send_and_receive
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
def _send_and_receive(self, target, lun, netfn, cmdid, payload):
Function send_and_receive_raw
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
def send_and_receive_raw(self, target, lun, netfn, raw_bytes):
Function __init__
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
def __init__(self, slave_address=0x81, host_target_address=0x20,