dragonchain/dragonchain

View on GitHub
dragonchain/lib/keys.py

Summary

Maintainability
C
1 day
Test Coverage
F
40%

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 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 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

      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

      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 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 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

                  There are no issues that match your filters.

                  Category
                  Status