File redisearch.py
has 389 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:
Function _generate_transaction_indexes
has a Cognitive Complexity of 28 (exceeds 5 allowed). Consider refactoring. Open
def _generate_transaction_indexes() -> None: # noqa: C901
# -- CREATE INDEXES FOR TRANSACTIONS --
client = _get_redisearch_index_client(Indexes.transaction.value)
try:
client.create_index([redisearch.TagField("block_id")]) # Used for reverse-lookup of transactions by id (with no txn_type)
- 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 _generate_l5_verification_indexes
has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring. Open
def _generate_l5_verification_indexes() -> None:
client = _get_redisearch_index_client(Indexes.verification.value)
try:
client.create_index(
[
- 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 _generate_block_indexes
has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring. Open
def _generate_block_indexes() -> None:
client = _get_redisearch_index_client(Indexes.block.value)
try:
client.create_index(
[
- 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_custom_field_from_input
has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring. Open
def _get_custom_field_from_input(custom_index_input: "custom_index") -> redisearch.client.Field:
input_type = custom_index_input["type"]
field_name = custom_index_input["field_name"]
options = custom_index_input.get("options")
if input_type == "text":
- 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 search
has 8 arguments (exceeds 4 allowed). Consider refactoring. Open
def search(
Function search
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
def search(
index: str,
query_str: str,
only_id: Optional[bool] = None,
verbatim: Optional[bool] = 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
Avoid deeply nested control flow statements. Open
if watch_block and int(txn_model.block_id) >= watch_block:
txn_model.extract_custom_indexes(txn_type_models[txn_model.txn_type])
put_document(txn_model.txn_type, txn_model.txn_id, txn_model.export_as_search_index(), upsert=True)
client.redis.sadd(TXN_MIGRATION_KEY, txn_path)
Function put_document
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
def put_document(index: str, doc_name: str, fields: Dict[str, Any], upsert: bool = False, partial_update: bool = False) -> None: