gappleto97/Senior-Project

View on GitHub

Showing 22 of 114 total issues

File peers.py has 402 lines of code (exceeds 250 allowed). Consider refactoring.
Open

from multiprocessing import Queue
import multiprocessing, os, pickle, select, socket, sys, time, rsa, traceback
from common.safeprint import safeprint
from common.bounty import *

Severity: Minor
Found in common/peers.py - About 5 hrs to fix

    File bounty.py has 340 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    import os, pickle, re, sys, rsa
    from common.safeprint import safeprint
    from common.call import parse
    from multiprocessing import Lock
    from hashlib import sha256
    Severity: Minor
    Found in common/bounty.py - About 4 hrs to fix

      Function listenp has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
      Open

      def listenp(port, v):
          """BLOCKING function which should only be run in a daemon thread. Listens and responds to other nodes"""
          import time
          while v.value:   # is True is implicit
              safeprint("listenp-ing", verbosity=3)
      Severity: Minor
      Found in common/peers.py - About 2 hrs 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 listen has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
      Open

      def listen(port, outbound, q, v, serv):
          """BLOCKING function which should only be run in a daemon thread. Listens and responds to other nodes"""
          if serv:
              from server.bounty import verify, addBounty
          server = socket.socket()
      Severity: Minor
      Found in common/peers.py - About 2 hrs 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 process has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
      Open

      def process(tup):
          """Convert tuples into a format readable by call.call"""
          args = []
          ix = None
          ex = None
      Severity: Minor
      Found in common/call.py - About 55 mins 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 main has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
      Open

      def main():
          # Begin Init
          settings.setup()
          try:
              import miniupnpc
      Severity: Minor
      Found in main.py - About 55 mins 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 call has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
      Open

      def call(mod, cmd, *args, **kargs):
          """Calls arbitrary python code
      
          Arguments:
              mod     - The module from which you are calling
      Severity: Minor
      Found in common/call.py - About 55 mins 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 depickle has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
      Open

      def depickle(string):
          """Handles the potential errors in unpickling a bounty"""
          if isinstance(string, Bounty):
              return string
          safeprint([sys.version_info[0], sys.version_info[1], sys.version_info[2]])
      Severity: Minor
      Found in common/bounty.py - About 45 mins 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 isValid has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
      Open

          def isValid(self):
              """Internal method which checks the Bounty as valid in the most minimal version
      
              ip      -- Must be in valid range
              btc     -- Must be in valid namespace
      Severity: Minor
      Found in common/bounty.py - About 45 mins 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 verify has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
      Open

      def verify(string):
          """External method which checks the Bounty as valid under implementation-specific requirements. This can be defined per user.
      
          ip      -- Must be in valid range
          btc     -- Must be in valid namespace
      Severity: Minor
      Found in common/bounty.py - About 45 mins 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 handleBountyRequest has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
      Open

      def handleBountyRequest(conn, exchange, key=None, received=[]):
          """Given a socket, send the proper messages to complete a bounty request"""
          unfiltered = getBountyList()
          filtered = list(set(unfiltered) - set(received))
          toSend = pickle.dumps(filtered, 0)
      Severity: Minor
      Found in common/peers.py - About 45 mins 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 5 arguments (exceeds 4 allowed). Consider refactoring.
      Open

          def __init__(self, port, outbound, q, v, serv):
      Severity: Minor
      Found in common/peers.py - About 35 mins to fix

        Function listen has 5 arguments (exceeds 4 allowed). Consider refactoring.
        Open

        def listen(port, outbound, q, v, serv):
        Severity: Minor
        Found in common/peers.py - About 35 mins to fix

          Function addBounties has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
          Open

          def addBounties(bounties):
              """Add a list of bounties in parallel using multiprocessing.Pool for verification"""
              from multiprocessing.pool import ThreadPool
              pool = ThreadPool()
              safeprint("Mapping verifications", verbosity=3)
          Severity: Minor
          Found in common/bounty.py - About 35 mins 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

          Avoid too many return statements within this function.
          Open

                      return False
          Severity: Major
          Found in common/bounty.py - About 30 mins to fix

            Avoid too many return statements within this function.
            Open

                    return False
            Severity: Major
            Found in common/bounty.py - About 30 mins to fix

              Avoid too many return statements within this function.
              Open

                          return 1
              Severity: Major
              Found in common/bounty.py - About 30 mins to fix

                Avoid too many return statements within this function.
                Open

                        return -1
                Severity: Major
                Found in common/bounty.py - About 30 mins to fix

                  Avoid too many return statements within this function.
                  Open

                              return -1
                  Severity: Major
                  Found in common/bounty.py - About 30 mins to fix

                    Avoid too many return statements within this function.
                    Open

                                    return 1
                    Severity: Major
                    Found in common/bounty.py - About 30 mins to fix
                      Severity
                      Category
                      Status
                      Source
                      Language