dragonchain/dragonchain

View on GitHub

Showing 114 of 114 total issues

Function setup has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

def setup() -> Tuple[Dict[str, str], Any]:
    cron_trigger = {"second": "*/1"}
    if LEVEL == "1":
        cron_trigger = {"second": "*/5"}
        from dragonchain.transaction_processor import level_1_actions as processor
Severity: Minor
Found in dragonchain/transaction_processor/transaction_processor.py - About 25 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 execute has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

def execute() -> None:
    """Gets the next L3 block content from the queue and processes it"""
    matchmaking.renew_registration_if_necessary()
    t0 = time.time()

Severity: Minor
Found in dragonchain/transaction_processor/level_4_actions.py - About 25 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 build_contract_image has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    def build_contract_image(self) -> None:
        """Build a smart contract to OpenFaaS"""
        self.docker = docker.from_env()
        self.docker_login_if_necessary()

Severity: Minor
Found in dragonchain/job_processor/contract_job.py - About 25 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 get_transaction_fee_estimate has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    def get_transaction_fee_estimate(self) -> int:
        """Calculate the transaction fee estimate for a transaction given current fee rates
        Returns:
            The amount of estimated transaction fee cost for the network
        """
Severity: Minor
Found in dragonchain/lib/dto/bnb.py - About 25 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 _decode_set_response has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

def _decode_set_response(response: Iterable[Any], decode: bool) -> Any:
    if decode is True:
        new_response = set()
        for val in response:
            if isinstance(val, bytes):
Severity: Minor
Found in dragonchain/lib/database/redis.py - About 25 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 get_pending_l4_blocks has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

def get_pending_l4_blocks(block_id: str) -> List[str]:
    all_waiting_verification_keys = storage.list_objects(f"BROADCAST/TO_BROADCAST/{block_id}")

    l4_blocks = []
    for key in all_waiting_verification_keys:
Severity: Minor
Found in dragonchain/transaction_processor/level_5_actions.py - About 25 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 get_version has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

def get_version(package):
    r = requests.get(f"https://pypi.python.org/pypi/{package}/json")
    version = parse("0")
    if r.status_code == 200:
        for release in r.json().get("releases", []):
Severity: Minor
Found in scripts/check_packages.py - About 25 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 execute has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

def execute() -> None:
    """
    * Pops Level 4 records off the queue and Sets them to storage in directory called toBroadcast-${block_id}
    * Publishes to public nodes when required
    * Locates confirmations from public nodes when required
Severity: Minor
Found in dragonchain/transaction_processor/level_5_actions.py - About 25 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 public_blockchain_transaction_v1 has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

def public_blockchain_transaction_v1(**kwargs) -> Tuple[str, int, Dict[str, str]]:
    if not flask.request.is_json:
        raise exceptions.BadRequest("Could not parse JSON")

    data = flask.request.json
Severity: Minor
Found in dragonchain/webserver/routes/interchain.py - About 25 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 _decode_list_response has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

def _decode_list_response(response: Iterable[Any], decode: bool) -> Any:
    if decode is True:
        new_response = []
        for val in response:
            if isinstance(val, bytes):
Severity: Minor
Found in dragonchain/lib/database/redis.py - About 25 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 list_objects has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

def list_objects(location: str, prefix: str) -> List[str]:
    """List S3 keys under a common prefix
    Args:
        location: The S3 bucket to use
        prefix: The prefix key to scan
Severity: Minor
Found in dragonchain/lib/interfaces/aws/s3.py - About 25 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 list_objects has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

def list_objects(location: str, prefix: str) -> List[str]:
    prefix = process_key(prefix)
    directory = os.path.dirname(prefix)
    base = os.path.join(location, directory)
    prefixed_keys = []
Severity: Minor
Found in dragonchain/lib/interfaces/local/disk.py - About 25 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 new_from_scratch has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

def new_from_scratch(smart_contract: bool = False, nickname: str = "", interchain_dcid: str = "") -> "APIKeyModel":
    """Create a new api key model from scratch, generating necessary fields
    Args:
        smart_contract: Whether or not this key is for a smart contract
        nickname: The nickname for this api key
Severity: Minor
Found in dragonchain/lib/dto/api_key_model.py - About 25 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 get_requirements_packages has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

def get_requirements_packages():
    packages = []
    with open(os.path.join(pathlib.Path(os.path.dirname(os.path.realpath(__file__))).parent, "requirements.txt"), "r") as f:
        for line in f:
            line = line.rstrip()
Severity: Minor
Found in scripts/check_packages.py - About 25 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

Severity
Category
Status
Source
Language