asterisk/ami/client.py
AMIClient
has 24 functions (exceeds 20 allowed). Consider refactoring. Open
Open
class AMIClient(object):
asterisk_start_regex = re.compile(r'^Asterisk *Call *Manager/(?P<version>([0-9]+\.)*[0-9]+)', re.IGNORECASE)
asterisk_line_regex = re.compile(b'\r\n', re.IGNORECASE | re.MULTILINE)
asterisk_pack_regex = re.compile(b'\r\n\r\n', re.IGNORECASE | re.MULTILINE)
File client.py
has 274 lines of code (exceeds 250 allowed). Consider refactoring. Open
Open
import re
import socket
import threading
from functools import partial
Function _next_pack
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
Open
def _next_pack(self):
data = b''
while not self.finished.is_set():
recv = self._socket.recv(self._buffer_size)
if recv == b'':
- 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 __init__
has 7 arguments (exceeds 4 allowed). Consider refactoring. Open
Open
def __init__(self, address='127.0.0.1', port=5038,
Function _login_wrapper
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
Open
def _login_wrapper(self, *args, **kwargs):
callback = kwargs.pop('callback', None) or (lambda *a, **k: None)
def on_login(response, *a, **k):
if not response.is_error():
- 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"