dragonchain/dragonchain

View on GitHub

Showing 114 of 114 total issues

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

    def __init__(
Severity: Major
Found in dragonchain/lib/dto/api_key_model.py - About 50 mins to fix

    Function submit_bulk_transaction_v1 has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

    def submit_bulk_transaction_v1(bulk_transaction: Sequence[Dict[str, Any]], api_key: "api_key_model.APIKeyModel") -> Dict[str, List[Any]]:
        """
        Formats, validates and enqueues the transactions in
        the payload of bulk_transaction
        Returns dictionary of 2 lists, key "201" are successfully created txn ids and key "400" are transactions that failed to post (entire dto passed in from user)
    Severity: Minor
    Found in dragonchain/webserver/lib/transactions.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 query_blocks_v1 has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

    def query_blocks_v1(params: Dict[str, Any], parse: bool = False) -> "RSearch":
        """Returns block matching block id, with query parameters accepted.
        Args:
            block_id: string Block id to search for.
            params: Dictionary of redisearch query options
    Severity: Minor
    Found in dragonchain/webserver/lib/blocks.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

    Avoid deeply nested control flow statements.
    Open

                        if watch_block and int(txn_model.block_id) >= watch_block:
                            txn_model.extract_custom_indexes(txn_type_models[txn_model.txn_type])
                            put_document(txn_model.txn_type, txn_model.txn_id, txn_model.export_as_search_index(), upsert=True)
                client.redis.sadd(TXN_MIGRATION_KEY, txn_path)
    Severity: Major
    Found in dragonchain/lib/database/redisearch.py - About 45 mins to fix

      Function initialize has 6 arguments (exceeds 4 allowed). Consider refactoring.
      Open

          def initialize(
      Severity: Minor
      Found in dragonchain/lib/keys.py - About 45 mins to fix

        Avoid deeply nested control flow statements.
        Open

                                    if isinstance(index_item, str):
                                        transaction_index_object[field_name] = index_item
                                    else:
                                        _log.warning(f"Provided value {index_item} for field {field_name} was not a string. Can't index")
                                # Check that the item we extracted is (or converts to) a valid number for number type custom indexes
        Severity: Major
        Found in dragonchain/lib/dto/transaction_model.py - About 45 mins to fix

          Function create_block has 6 arguments (exceeds 4 allowed). Consider refactoring.
          Open

          def create_block(
          Severity: Minor
          Found in dragonchain/transaction_processor/level_3_actions.py - About 45 mins to fix

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

                def __init__(self, name: str, testnet: bool, node_url: str, rpc_port: int, api_port: int, b64_private_key: str):
            Severity: Minor
            Found in dragonchain/lib/dto/bnb.py - About 45 mins to fix

              Function attempt_job_launch has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
              Open

              def attempt_job_launch(event: dict, retry: int = 0) -> None:
                  """Launch kubernetes namespaced job given a smart contract invocation
                  Args:
                      event: An invocation of a smart contract
                      retry: The retry count for recursive invocation (dont specify manually)
              Severity: Minor
              Found in dragonchain/job_processor/job_processor.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 zadd_sync has 6 arguments (exceeds 4 allowed). Consider refactoring.
              Open

              def zadd_sync(name: str, mapping: Dict[str, int], nx: bool = False, xx: bool = False, ch: bool = False, incr: bool = False) -> int:
              Severity: Minor
              Found in dragonchain/lib/database/redis.py - About 45 mins to fix

                Function hash_l4_block has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                Open

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

                Consider simplifying this complex logical expression.
                Open

                        if (not cron and not seconds) or (cron and seconds) or not execution_order or not txn_type:
                            raise exceptions.TimingEventSchedulerError("BAD_REQUEST")
                        if cron:
                Severity: Major
                Found in dragonchain/scheduler/timing_event.py - About 40 mins to fix

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

                      def __init__(
                  Severity: Minor
                  Found in dragonchain/scheduler/timing_event.py - About 35 mins to fix

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

                    def add_receipt(l1_block_id: str, level: int, dc_id: str, block_id: str, proof: str) -> None:
                    Severity: Minor
                    Found in dragonchain/lib/matchmaking.py - About 35 mins to fix

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

                      def put_document(index: str, doc_name: str, fields: Dict[str, Any], upsert: bool = False, partial_update: bool = False) -> None:
                      Severity: Minor
                      Found in dragonchain/lib/database/redisearch.py - About 35 mins to fix

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

                        def make_matchmaking_request(
                        Severity: Minor
                        Found in dragonchain/lib/matchmaking.py - About 35 mins to fix

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

                              def is_key_allowed(
                          Severity: Minor
                          Found in dragonchain/lib/dto/api_key_model.py - About 35 mins to fix

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

                            def check_generic_signature(
                            Severity: Minor
                            Found in dragonchain/lib/crypto.py - About 35 mins to fix

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

                              def generate_authenticated_request(
                              Severity: Minor
                              Found in dragonchain/lib/authorization.py - About 35 mins to fix

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

                                def verify_block(
                                Severity: Minor
                                Found in dragonchain/transaction_processor/level_3_actions.py - About 35 mins to fix
                                  Severity
                                  Category
                                  Status
                                  Source
                                  Language