YuntechNet/AtomicP2P

View on GitHub
atomic_p2p/peer/peer.py

Summary

Maintainability
C
1 day
Test Coverage

File peer.py has 269 lines of code (exceeds 250 allowed). Consider refactoring.
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
Severity: Minor
Found in atomic_p2p/peer/peer.py - About 2 hrs to fix

    Peer has 22 functions (exceeds 20 allowed). Consider refactoring.
    Open

    class Peer(
        HandleableMixin, CommandableMixin, LanTopologyMixin, DefaultAuthenticatorMixin
    ):
        """
        Attributes:
    Severity: Minor
    Found in atomic_p2p/peer/peer.py - About 2 hrs to fix

      Function __on_send has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
      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:
      Severity: Minor
      Found in atomic_p2p/peer/peer.py - About 1 hr to fix

      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

          def __on_recv(self, sock: "Socket", mask, **kwargs):
              """Method use when recieve socket data.
              This is 2th layer to process Packets.
              """
              try:
      Severity: Minor
      Found in atomic_p2p/peer/peer.py - About 1 hr to fix

      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

          def __init__(
      Severity: Major
      Found in atomic_p2p/peer/peer.py - About 1 hr to fix

        There are no issues that match your filters.

        Category
        Status