migraf/fhir-kindling

View on GitHub
fhir_kindling/util/references.py

Summary

Maintainability
B
5 hrs
Test Coverage

Function extract_references has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
Open

def extract_references(resource: Resource) -> List[Tuple[str, str, str, bool]]:
    """
    Extracts the references from a resource and returns them as a list of dicts.
    Args:
        resource: fhir resource object to extract references from.
Severity: Minor
Found in fhir_kindling/util/references.py - About 2 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 _get_missing_references has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
Open

def _get_missing_references(references: dict, resource_ids: dict) -> List[str]:
    missing_references = []
    for ref_resource, reference_set in references.items():
        # get set of resource ids for this resource type
        id_set = resource_ids.get(ref_resource)
Severity: Minor
Found in fhir_kindling/util/references.py - About 1 hr 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 _resource_ids_from_query_response has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
Open

def _resource_ids_from_query_response(response: QueryResponse) -> dict:
    contained_resources = {}
    for resource in response.resources:
        resource_id_set = contained_resources.get(resource.resource_type)
        if resource_id_set is None:
Severity: Minor
Found in fhir_kindling/util/references.py - About 55 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

Avoid deeply nested control flow statements.
Open

                    for value in field_value:
                        resource, resource_id = value.get("reference").split("/")
                        references.append((field.name, resource, resource_id, True))
                # add the reference
                else:
Severity: Major
Found in fhir_kindling/util/references.py - About 45 mins to fix

    There are no issues that match your filters.

    Category
    Status