dragonchain/dragonchain

View on GitHub
dragonchain/lib/dto/transaction_model.py

Summary

Maintainability
B
6 hrs
Test Coverage
F
56%

Function extract_custom_indexes has a Cognitive Complexity of 28 (exceeds 5 allowed). Consider refactoring.
Open

    def extract_custom_indexes(self, transaction_type_model: "transaction_type_model.TransactionTypeModel") -> None:
        """Extracts and formats custom indexed data paths from payload"""
        transaction_index_object: Dict[str, Any] = {}
        if transaction_type_model.custom_indexes:
            # Make sure the payload is valid json before trying to extract indexes
Severity: Minor
Found in dragonchain/lib/dto/transaction_model.py - About 4 hrs 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 __init__ has 10 arguments (exceeds 4 allowed). Consider refactoring.
Open

    def __init__(
Severity: Major
Found in dragonchain/lib/dto/transaction_model.py - About 1 hr to fix

    Avoid deeply nested control flow statements.
    Open

                                if isinstance(index_item, str):
                                    transaction_index_object[field_name] = index_item
                                else:
                                    _log.warning(f"Provided value {index_item} for field {field_name} was not a string. Can't index")
                            # Check that the item we extracted is (or converts to) a valid number for number type custom indexes
    Severity: Major
    Found in dragonchain/lib/dto/transaction_model.py - About 45 mins to fix

      There are no issues that match your filters.

      Category
      Status