dragonchain/dragonchain

View on GitHub

Showing 114 of 114 total issues

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

    def __init__(self, name: str, rpc_address: str, testnet: bool, b64_private_key: str, authorization: Optional[str] = None):
Severity: Minor
Found in dragonchain/lib/dto/btc.py - About 35 mins to fix

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

    def make_broadcast_futures(session: aiohttp.ClientSession, block_id: str, level: int, chain_ids: set) -> Optional[Set[asyncio.Task]]:
        """Initiate broadcasts for a block id to certain higher level nodes
        Args:
            session: aiohttp session to use for making http requests
            block_id: the block id to broadcast
    Severity: Minor
    Found in dragonchain/broadcast_processor/broadcast_processor.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

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

        def sign_block(self, signable_block: "model.BlockModel") -> str:
            """Sign a block with this class' keys
            Args:
                block: BlockModel to sign
            Returns:
    Severity: Minor
    Found in dragonchain/lib/keys.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

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

    def hash_l3_block(hash_type: SupportedHashes, block: "l3_block_model.L3BlockModel", nonce: int = 0) -> bytes:
        """Hash an l3 block
        Args:
            hash_type: SupportedHashes enum type
            block: L3BlockModel with appropriate data to hash
    Severity: Minor
    Found in dragonchain/lib/crypto.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

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

    def get(key: str, cache_expire: Optional[int] = None, should_cache: bool = True) -> bytes:
        """Returns an object from storage
        Args:
            key: The key to get from storage
            cache_expire: The amount of time (in seconds) until the key expires if cache miss
    Severity: Minor
    Found in dragonchain/lib/interfaces/storage.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

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

    def start_task() -> None:
        task_definition = get_next_task()
        if task_definition:
            job = get_existing_job_status(task_definition)
            if job and job.status.active:
    Severity: Minor
    Found in dragonchain/job_processor/job_processor.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

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

    def verify_custom_indexes_options(custom_indexes: Iterable["custom_index"]) -> None:
        """Validate an array of custom index DTOs from user input (Raises on error)"""
        for index in custom_indexes:
            index_type = index.get("type")
            if index_type == "text":
    Severity: Minor
    Found in dragonchain/webserver/helpers.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

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

    def get_next_item() -> Optional[Any]:
        """Get and json.loads the next item from the queue"""
        item = cast(bytes, redis.rpoplpush_sync(INCOMING_TX_KEY, PROCESSING_TX_KEY, decode=False))
        if item is not None:
            if LEVEL != "1":
    Severity: Minor
    Found in dragonchain/lib/queue.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

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

    def get_registered_transaction_types_or_default(transaction_types: Iterable[str]) -> Dict[str, transaction_type_model.TransactionTypeModel]:
        """Bulk get of registered transaction types
           Note: If a transaction type is not found, it is sent back as a TransactionTypeModel with default values
        Args:
            transaction_types: a list of transaction types to fetch models for
    Severity: Minor
    Found in dragonchain/lib/dao/transaction_type_dao.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

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

    def bech32_decode(bech):
        """Validate a Bech32 string, and determine HRP and data."""
        if (any(ord(x) < 33 or ord(x) > 126 for x in bech)) or (bech.lower() != bech and bech.upper() != bech):
            return None, None
        bech = bech.lower()
    Severity: Minor
    Found in dragonchain/lib/segwit_addr.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 crypto.verify_l5_block_trust(self.hash, self.encryption, self.pub, cast("l5_block_model.L5BlockModel", block))
    Severity: Major
    Found in dragonchain/lib/keys.py - About 30 mins to fix

      Avoid too many return statements within this function.
      Open

          return hrp, data[:-6]
      Severity: Major
      Found in dragonchain/lib/segwit_addr.py - About 30 mins to fix

        Avoid too many return statements within this function.
        Open

                        return crypto.verify_l4_block_trust(self.hash, self.encryption, self.pub, cast("l4_block_model.L4BlockModel", block))
        Severity: Major
        Found in dragonchain/lib/keys.py - About 30 mins to fix

          Avoid too many return statements within this function.
          Open

                          return crypto.verify_l4_block_pow(self.hash, cast("l4_block_model.L4BlockModel", block))
          Severity: Major
          Found in dragonchain/lib/keys.py - About 30 mins to fix

            Avoid too many return statements within this function.
            Open

                return allowed
            Severity: Major
            Found in dragonchain/lib/dto/api_key_model.py - About 30 mins to fix

              Avoid too many return statements within this function.
              Open

                          return crypto.sign_l5_block(self.hash, self.encryption, self.priv, signable_block)
              Severity: Major
              Found in dragonchain/lib/keys.py - About 30 mins to fix

                Avoid too many return statements within this function.
                Open

                                return crypto.verify_l3_block_trust(self.hash, self.encryption, self.pub, cast("l3_block_model.L3BlockModel", block))
                Severity: Major
                Found in dragonchain/lib/keys.py - About 30 mins to fix

                  Avoid too many return statements within this function.
                  Open

                                  return crypto.verify_l3_block_pow(self.hash, cast("l3_block_model.L3BlockModel", block))
                  Severity: Major
                  Found in dragonchain/lib/keys.py - About 30 mins to fix

                    Function get_pending_l4_blocks has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                    Open

                    def get_pending_l4_blocks(block_id: str) -> List[str]:
                        all_waiting_verification_keys = storage.list_objects(f"BROADCAST/TO_BROADCAST/{block_id}")
                    
                        l4_blocks = []
                        for key in all_waiting_verification_keys:
                    Severity: Minor
                    Found in dragonchain/transaction_processor/level_5_actions.py - About 25 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 bech32_polymod has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                    Open

                    def bech32_polymod(values):
                        """Internal function that computes the Bech32 checksum."""
                        generator = [0x3B6A57B2, 0x26508E6D, 0x1EA119FA, 0x3D4233DD, 0x2A1462B3]
                        chk = 1
                        for value in values:
                    Severity: Minor
                    Found in dragonchain/lib/segwit_addr.py - About 25 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

                    Severity
                    Category
                    Status
                    Source
                    Language