dragonchain/dragonchain

View on GitHub

Showing 114 of 114 total issues

File schema.py has 761 lines of code (exceeds 250 allowed). Consider refactoring.
Open

# Copyright 2020 Dragonchain, Inc.
# Licensed under the Apache License, Version 2.0 (the "Apache License")
# with the following modification; you may not use this file except in
# compliance with the Apache License and the following modification to it:
# Section 6. Trademarks. is deleted and replaced with:
Severity: Major
Found in dragonchain/lib/dto/schema.py - About 1 day to fix

    File crypto.py has 634 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    # Copyright 2020 Dragonchain, Inc.
    # Licensed under the Apache License, Version 2.0 (the "Apache License")
    # with the following modification; you may not use this file except in
    # compliance with the Apache License and the following modification to it:
    # Section 6. Trademarks. is deleted and replaced with:
    Severity: Major
    Found in dragonchain/lib/crypto.py - About 1 day to fix

      File contract_job.py has 431 lines of code (exceeds 250 allowed). Consider refactoring.
      Open

      # Copyright 2020 Dragonchain, Inc.
      # Licensed under the Apache License, Version 2.0 (the "Apache License")
      # with the following modification; you may not use this file except in
      # compliance with the Apache License and the following modification to it:
      # Section 6. Trademarks. is deleted and replaced with:
      Severity: Minor
      Found in dragonchain/job_processor/contract_job.py - About 6 hrs to fix

        Function new_from_user_input has a Cognitive Complexity of 38 (exceeds 5 allowed). Consider refactoring.
        Open

        def new_from_user_input(user_input: Dict[str, Any]) -> "BinanceNetwork":  # noqa: C901
            """Create a new BinanceNetwork model from user input
            Args:
                user_input: User dictionary input (assumed already passing create_binance_interchain_schema)
            Returns:
        Severity: Minor
        Found in dragonchain/lib/dto/bnb.py - About 5 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 verify_request_authorization has a Cognitive Complexity of 36 (exceeds 5 allowed). Consider refactoring.
        Open

        def verify_request_authorization(  # noqa: C901
            authorization: str,
            http_verb: str,
            full_path: str,
            dcid: str,
        Severity: Minor
        Found in dragonchain/lib/authorization.py - About 5 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

        File redisearch.py has 389 lines of code (exceeds 250 allowed). Consider refactoring.
        Open

        # Copyright 2020 Dragonchain, Inc.
        # Licensed under the Apache License, Version 2.0 (the "Apache License")
        # with the following modification; you may not use this file except in
        # compliance with the Apache License and the following modification to it:
        # Section 6. Trademarks. is deleted and replaced with:
        Severity: Minor
        Found in dragonchain/lib/database/redisearch.py - About 5 hrs to fix

          Function new_from_user_input has a Cognitive Complexity of 33 (exceeds 5 allowed). Consider refactoring.
          Open

          def new_from_user_input(user_input: Dict[str, Any]) -> "EthereumNetwork":  # noqa: C901
              """Create a new EthereumNetwork model from user input
              Args:
                  user_input: User dictionary input (assumed already passing create_ethereum_interchain_schema)
              Returns:
          Severity: Minor
          Found in dragonchain/lib/dto/eth.py - About 4 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

          File keys.py has 357 lines of code (exceeds 250 allowed). Consider refactoring.
          Open

          # Copyright 2020 Dragonchain, Inc.
          # Licensed under the Apache License, Version 2.0 (the "Apache License")
          # with the following modification; you may not use this file except in
          # compliance with the Apache License and the following modification to it:
          # Section 6. Trademarks. is deleted and replaced with:
          Severity: Minor
          Found in dragonchain/lib/keys.py - About 4 hrs to fix

            Function extract_custom_indexes has a Cognitive Complexity of 28 (exceeds 5 allowed). Consider refactoring.
            Open

                def extract_custom_indexes(self, transaction_type_model: "transaction_type_model.TransactionTypeModel") -> None:
                    """Extracts and formats custom indexed data paths from payload"""
                    transaction_index_object: Dict[str, Any] = {}
                    if transaction_type_model.custom_indexes:
                        # Make sure the payload is valid json before trying to extract indexes
            Severity: Minor
            Found in dragonchain/lib/dto/transaction_model.py - About 4 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 _generate_transaction_indexes has a Cognitive Complexity of 28 (exceeds 5 allowed). Consider refactoring.
            Open

            def _generate_transaction_indexes() -> None:  # noqa: C901
                # -- CREATE INDEXES FOR TRANSACTIONS --
                client = _get_redisearch_index_client(Indexes.transaction.value)
                try:
                    client.create_index([redisearch.TagField("block_id")])  # Used for reverse-lookup of transactions by id (with no txn_type)
            Severity: Minor
            Found in dragonchain/lib/database/redisearch.py - About 4 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

            File bnb.py has 334 lines of code (exceeds 250 allowed). Consider refactoring.
            Open

            # Copyright 2020 Dragonchain, Inc.
            # Licensed under the Apache License, Version 2.0 (the "Apache License")
            # with the following modification; you may not use this file except in
            # compliance with the Apache License and the following modification to it:
            # Section 6. Trademarks. is deleted and replaced with:
            Severity: Minor
            Found in dragonchain/lib/dto/bnb.py - About 4 hrs to fix

              Function verify_block has a Cognitive Complexity of 27 (exceeds 5 allowed). Consider refactoring.
              Open

                  def verify_block(self, block: "model.BlockModel") -> bool:  # noqa: C901
                      """Verify a block with this class' keys
                      Args:
                          block: BlockModel to verify
                      Returns:
              Severity: Minor
              Found in dragonchain/lib/keys.py - About 3 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 new_from_user_input has a Cognitive Complexity of 27 (exceeds 5 allowed). Consider refactoring.
              Open

              def new_from_user_input(user_input: Dict[str, Any]) -> "BitcoinNetwork":
                  """Create a new BitcoinNetwork model from user input
                  Args:
                      user_input: User dictionary input (assumed already passing create_bitcoin_interchain_schema)
                  Returns:
              Severity: Minor
              Found in dragonchain/lib/dto/btc.py - About 3 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 webserver_error_handler has a Cognitive Complexity of 25 (exceeds 5 allowed). Consider refactoring.
              Open

              def webserver_error_handler(exception: Exception) -> Tuple[str, int, Dict[str, str]]:  # noqa C901
                  if isinstance(exception, exceptions.UnauthorizedException):
                      status_code = 401
                      surface_error = invalid_auth(exception)
                  elif isinstance(exception, exceptions.APIRateLimitException):
              Severity: Minor
              Found in dragonchain/webserver/helpers.py - About 3 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

              File authorization.py has 303 lines of code (exceeds 250 allowed). Consider refactoring.
              Open

              # Copyright 2020 Dragonchain, Inc.
              # Licensed under the Apache License, Version 2.0 (the "Apache License")
              # with the following modification; you may not use this file except in
              # compliance with the Apache License and the following modification to it:
              # Section 6. Trademarks. is deleted and replaced with:
              Severity: Minor
              Found in dragonchain/lib/authorization.py - About 3 hrs to fix

                File matchmaking.py has 295 lines of code (exceeds 250 allowed). Consider refactoring.
                Open

                # Copyright 2020 Dragonchain, Inc.
                # Licensed under the Apache License, Version 2.0 (the "Apache License")
                # with the following modification; you may not use this file except in
                # compliance with the Apache License and the following modification to it:
                # Section 6. Trademarks. is deleted and replaced with:
                Severity: Minor
                Found in dragonchain/lib/matchmaking.py - About 3 hrs to fix

                  Function process_receipt_v1 has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring.
                  Open

                  def process_receipt_v1(block_dto: Dict[str, Any]) -> None:
                      if not block_dto:
                          raise exceptions.ValidationException("block_dto missing")
                      _log.info(f"[RECEIPT] Got receipt from L{block_dto['header']['level']}: {block_dto}")
                      block_model = cast("model.BlockModel", None)  # This will always get defined, or it will raise
                  Severity: Minor
                  Found in dragonchain/webserver/lib/dragonnet.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

                  File broadcast_processor.py has 288 lines of code (exceeds 250 allowed). Consider refactoring.
                  Open

                  # Copyright 2020 Dragonchain, Inc.
                  # Licensed under the Apache License, Version 2.0 (the "Apache License")
                  # with the following modification; you may not use this file except in
                  # compliance with the Apache License and the following modification to it:
                  # Section 6. Trademarks. is deleted and replaced with:
                  Severity: Minor
                  Found in dragonchain/broadcast_processor/broadcast_processor.py - About 2 hrs to fix

                    File btc.py has 287 lines of code (exceeds 250 allowed). Consider refactoring.
                    Open

                    # Copyright 2020 Dragonchain, Inc.
                    # Licensed under the Apache License, Version 2.0 (the "Apache License")
                    # with the following modification; you may not use this file except in
                    # compliance with the Apache License and the following modification to it:
                    # Section 6. Trademarks. is deleted and replaced with:
                    Severity: Minor
                    Found in dragonchain/lib/dto/btc.py - About 2 hrs to fix

                      Function send_receipts has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
                      Open

                      def send_receipts(l5_block: "l5_block_model.L5BlockModel") -> None:
                          receipt_path = "/v1/receipt"
                          get_claim_path = "/v1/claim"
                          chain_id_set = set()
                          _log.info(f"l5 block to loop {l5_block.__dict__}")
                      Severity: Minor
                      Found in dragonchain/lib/broadcast.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

                      Severity
                      Category
                      Status
                      Source
                      Language