atomic_p2p/peer/peer.py
File peer.py
has 269 lines of code (exceeds 250 allowed). Consider refactoring. Open
Open
from typing import Tuple, List
from traceback import format_exc
from selectors import DefaultSelector, EVENT_READ, EVENT_WRITE
from errno import ECONNRESET
from socket import error as sock_error
Peer
has 22 functions (exceeds 20 allowed). Consider refactoring. Open
Open
class Peer(
HandleableMixin, CommandableMixin, LanTopologyMixin, DefaultAuthenticatorMixin
):
"""
Attributes:
Function __on_send
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
Open
def __on_send(self, sock: "Socket", mask, **kwargs):
"""Method use when sending data to socket."""
q = self.__packet_queue[sock] if sock in self.__packet_queue else None
while q is not None and q.empty() is False:
try:
- 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 __on_recv
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
Open
def __on_recv(self, sock: "Socket", mask, **kwargs):
"""Method use when recieve socket data.
This is 2th layer to process Packets.
"""
try:
- 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 8 arguments (exceeds 4 allowed). Consider refactoring. Open
Open
def __init__(