File dragonchain_client.py
has 1290 lines of code (exceeds 250 allowed). Consider refactoring. Open
# Copyright 2020 Dragonchain, Inc. or its affiliates. All Rights Reserved.
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
# http://www.apache.org/licenses/LICENSE-2.0
Function _validate_and_build_custom_index_fields_array
has a Cognitive Complexity of 60 (exceeds 5 allowed). Consider refactoring. Open
def _validate_and_build_custom_index_fields_array( # noqa: C901
custom_index_fields: Iterable["custom_index_fields_type"],
) -> List["custom_index_fields_type"]:
"""Validate a list of custom index fields and return a list which can be passed as a body for custom indexes to the chain
- 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
Client
has 46 functions (exceeds 20 allowed). Consider refactoring. Wontfix
class Client(object):
def __init__(
self,
dragonchain_id: Optional[str],
auth_key_id: Optional[str],
Function update_smart_contract
has a Cognitive Complexity of 25 (exceeds 5 allowed). Consider refactoring. Open
def update_smart_contract( # noqa: C901
self,
smart_contract_id: str,
image: Optional[str] = None,
cmd: Optional[str] = None,
- 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 create_smart_contract
has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring. Open
def create_smart_contract( # noqa: C901
self,
transaction_type: str,
image: str,
cmd: str,
- 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 update_smart_contract
has 13 arguments (exceeds 4 allowed). Consider refactoring. Wontfix
def update_smart_contract( # noqa: C901
Function create_smart_contract
has 12 arguments (exceeds 4 allowed). Consider refactoring. Wontfix
def create_smart_contract( # noqa: C901
Function create_bitcoin_interchain
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
def create_bitcoin_interchain(
self,
name: str,
testnet: Optional[bool] = None,
private_key: Optional[str] = None,
- 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 update_bitcoin_interchain
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
def update_bitcoin_interchain(
self,
name: str,
testnet: Optional[bool] = None,
private_key: Optional[str] = None,
- 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 create_binance_interchain
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
def create_binance_interchain(
self,
name: str,
testnet: Optional[bool] = None,
private_key: Optional[str] = None,
- 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 update_binance_interchain
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
def update_binance_interchain(
self,
name: str,
testnet: Optional[bool] = None,
private_key: Optional[str] = None,
- 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 update_smart_contract
has 30 lines of code (exceeds 25 allowed). Consider refactoring. Open
def update_smart_contract( # noqa: C901
self,
smart_contract_id: str,
image: Optional[str] = None,
cmd: Optional[str] = None,
Function query_transactions
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
def query_transactions(
self,
transaction_type: str,
redisearch_query: str,
verbatim: bool = False,
- 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 _build_ethereum_transaction_body
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
def _build_ethereum_transaction_body(
to: str, value: str, data: Optional[str] = None, gas_price: Optional[str] = None, gas: Optional[str] = None, nonce: Optional[str] = None
) -> Dict[str, Any]:
"""Build the json (dictionary) body for an ethereum transaction given its inputs
- 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 create_smart_contract
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
def create_smart_contract( # noqa: C901
self,
transaction_type: str,
image: str,
cmd: str,
Function query_transactions
has 8 arguments (exceeds 4 allowed). Consider refactoring. Wontfix
def query_transactions(
Function sign_ethereum_transaction
has 7 arguments (exceeds 4 allowed). Consider refactoring. Wontfix
def sign_ethereum_transaction(
Function _build_ethereum_transaction_body
has 6 arguments (exceeds 4 allowed). Consider refactoring. Open
def _build_ethereum_transaction_body(
Function create_binance_interchain
has 6 arguments (exceeds 4 allowed). Consider refactoring. Open
def create_binance_interchain(
Function get_smart_contract_logs
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def get_smart_contract_logs(self, smart_contract_id: str, tail: Optional[int] = 100, since: Optional[str] = None) -> "request_response":
"""Perform a query on a chain's smart contracts logs
Args:
smart_contract_id (str): Id of the contract to get
- 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 update_bitcoin_interchain
has 6 arguments (exceeds 4 allowed). Consider refactoring. Open
def update_bitcoin_interchain(
Function create_ethereum_transaction
has 6 arguments (exceeds 4 allowed). Consider refactoring. Wontfix
def create_ethereum_transaction(
Function update_binance_interchain
has 6 arguments (exceeds 4 allowed). Consider refactoring. Open
def update_binance_interchain(
Function query_blocks
has 6 arguments (exceeds 4 allowed). Consider refactoring. Open
def query_blocks(
Function __init__
has 6 arguments (exceeds 4 allowed). Consider refactoring. Open
def __init__(
Function create_bitcoin_interchain
has 6 arguments (exceeds 4 allowed). Consider refactoring. Wontfix
def create_bitcoin_interchain(
Function _build_bitcoin_transaction_body
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def _build_bitcoin_transaction_body(
satoshis_per_byte: Optional[int] = None,
data: Optional[str] = None,
change_address: Optional[str] = None,
outputs: Optional[List[Dict[str, Any]]] = None,
- 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 create_bitcoin_transaction
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
def create_bitcoin_transaction(
Function sign_binance_transaction
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
def sign_binance_transaction(
Function sign_bitcoin_transaction
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
def sign_bitcoin_transaction(
Function query_blocks
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def query_blocks(
self, redisearch_query: str, offset: int = 0, limit: int = 10, sort_by: str = "", sort_ascending: bool = True, ids_only: bool = False
) -> "request_response":
"""Perform a query on a chain's blocks
- 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 get_smart_contract
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def get_smart_contract(self, smart_contract_id: Optional[str] = None, transaction_type: Optional[str] = None) -> "request_response":
"""Perform a query on a chain's smart contracts
Args:
smart_contract_id (str, exclusive): Id of the contract to get
- 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 create_ethereum_interchain
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def create_ethereum_interchain(
self, name: str, private_key: Optional[str] = None, rpc_address: Optional[str] = None, chain_id: Optional[int] = None
) -> "request_response":
"""Create (or overwrite) an ethereum wallet/network for interchain use
- 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 update_api_key
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def update_api_key(
self, key_id: str, nickname: Optional[str] = None, permissions_document: Optional["permissions_doc"] = None
) -> "request_response":
"""Update the nickname of an existing HMAC API key
- 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 update_ethereum_interchain
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def update_ethereum_interchain(
self, name: str, private_key: Optional[str] = None, rpc_address: Optional[str] = None, chain_id: Optional[int] = None
) -> "request_response":
"""Update an existing ethereum wallet/network for interchain use
- 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 list_smart_contract_objects
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def list_smart_contract_objects(self, prefix_key: Optional[str] = None, smart_contract_id: Optional[str] = None) -> "request_response":
"""Lists all objects stored in a smart contracts heap
Note: When ran in an actual smart contract, smart_contract_id will be pulled automatically from the environment if not explicitly provided
Args:
- 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 get_verifications
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def get_verifications(self, block_id: str, level: Optional[int] = None) -> "request_response":
"""Get higher level block verifications by level 1 block id
Args:
block_id (str): ID of the block to get verifications for
- 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 create_api_key
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def create_api_key(self, nickname: Optional[str] = None, permissions_document: Optional["permissions_doc"] = None) -> "request_response":
"""Generate a new HMAC API key
Args:
nickname (str, optional): The nickname to give to this new api key
- 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 _build_binance_transaction_body
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def _build_binance_transaction_body(amount: int, to_address: str, symbol: Optional[str] = None, memo: Optional[str] = None) -> Dict[str, Any]:
"""Build the json (dictionary) body for a binance transaction given its inputs
Args:
amount (int): amount of token in transaction
- 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"