dragonchain/dragonchain

View on GitHub
dragonchain/lib/crypto.py

Summary

Maintainability
D
1 day
Test Coverage
A
97%

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

    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

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

      There are no issues that match your filters.

      Category
      Status