dragonchain/lib/keys.py
File keys.py
has 357 lines of code (exceeds 250 allowed). Consider refactoring. Open
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:
Function verify_block
has a Cognitive Complexity of 27 (exceeds 5 allowed). Consider refactoring. Open
Open
def verify_block(self, block: "model.BlockModel") -> bool: # noqa: C901
"""Verify a block with this class' keys
Args:
block: BlockModel to verify
Returns:
- Read upRead up
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
Open
def initialize(
Function sign_block
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
Open
def sign_block(self, signable_block: "model.BlockModel") -> str:
"""Sign a block with this class' keys
Args:
block: BlockModel to sign
Returns:
- Read upRead up
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
Open
return crypto.verify_l5_block_trust(self.hash, self.encryption, self.pub, cast("l5_block_model.L5BlockModel", block))
Avoid too many return
statements within this function. Open
Open
return crypto.verify_l4_block_trust(self.hash, self.encryption, self.pub, cast("l4_block_model.L4BlockModel", block))
Avoid too many return
statements within this function. Open
Open
return crypto.verify_l4_block_pow(self.hash, cast("l4_block_model.L4BlockModel", block))
Avoid too many return
statements within this function. Open
Open
return crypto.sign_l5_block(self.hash, self.encryption, self.priv, signable_block)
Avoid too many return
statements within this function. Open
Open
return crypto.verify_l3_block_trust(self.hash, self.encryption, self.pub, cast("l3_block_model.L3BlockModel", block))
Avoid too many return
statements within this function. Open
Open
return crypto.verify_l3_block_pow(self.hash, cast("l3_block_model.L3BlockModel", block))