migraf/fhir-kindling

View on GitHub
fhir_kindling/fhir_query/base.py

Summary

Maintainability
D
2 days
Test Coverage

File base.py has 310 lines of code (exceeds 250 allowed). Consider refactoring.
Open

from inspect import signature
from typing import Any, Callable, List, TypeVar, Union

import fhir.resources
import httpx
Severity: Minor
Found in fhir_kindling/fhir_query/base.py - About 3 hrs to fix

    Function __repr__ has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
    Open

        def __repr__(self):
            resource = self.resource.resource_type
            if self.query_parameters.include_parameters:
                includes = []
                rev_includes = []
    Severity: Minor
    Found in fhir_kindling/fhir_query/base.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 include has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
    Open

        def include(
            self: T,
            resource: str = None,
            reference_param: str = None,
            target: str = None,
    Severity: Minor
    Found in fhir_kindling/fhir_query/base.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

    Consider simplifying this complex logical expression.
    Open

            if include_dict and include_param:
                raise ValueError("Cannot use both include_dict and include_param")
            elif include_dict and (resource or reference_param or target):
                raise ValueError("Cannot use both include_dict and kv parameters")
            elif include_param and (resource or reference_param or target):
    Severity: Critical
    Found in fhir_kindling/fhir_query/base.py - About 1 hr to fix

      Function where has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
      Open

          def where(
              self: T,
              field: str = None,
              operator: Union[QueryOperators, str] = None,
              value: Union[int, float, bool, str, list] = None,
      Severity: Minor
      Found in fhir_kindling/fhir_query/base.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 has has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
      Open

          def has(
              self: T,
              resource: str = None,
              reference_param: str = None,
              search_param: str = None,
      Severity: Minor
      Found in fhir_kindling/fhir_query/base.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 __init__ has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
      Open

          def __init__(
              self,
              base_url: str,
              resource: Union[
                  FHIRResourceModel, fhir.resources.FHIRAbstractModel, str
      Severity: Minor
      Found in fhir_kindling/fhir_query/base.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 _make_query_string has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
      Open

          def _make_query_string(self) -> str:
              """
              Make the query string from the query parameters
      
              Returns:
      Severity: Minor
      Found in fhir_kindling/fhir_query/base.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

      Function has has 6 arguments (exceeds 4 allowed). Consider refactoring.
      Open

          def has(
      Severity: Minor
      Found in fhir_kindling/fhir_query/base.py - About 45 mins to fix

        Function __init__ has 6 arguments (exceeds 4 allowed). Consider refactoring.
        Open

            def __init__(
        Severity: Minor
        Found in fhir_kindling/fhir_query/base.py - About 45 mins to fix

          Function include has 6 arguments (exceeds 4 allowed). Consider refactoring.
          Open

              def include(
          Severity: Minor
          Found in fhir_kindling/fhir_query/base.py - About 45 mins to fix

            Consider simplifying this complex logical expression.
            Open

                    if has_param and (
                        resource or reference_param or search_param or operator or value
                    ):
                        raise ValueError("Cannot use both has_param and kv parameters")
            
            
            Severity: Major
            Found in fhir_kindling/fhir_query/base.py - About 40 mins to fix

              Consider simplifying this complex logical expression.
              Open

                      if not has_param and not (
                          resource or reference_param or search_param or operator or value
                      ):
                          raise ValueError(
                              "Must provide either has_param or a valid set of kv parameters"
              Severity: Major
              Found in fhir_kindling/fhir_query/base.py - About 40 mins to fix

                Function _param_from_field has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                Open

                    def _param_from_field(field, operator, value):
                        if not (operator or operator == "") and value:
                            kv_error_message = (
                                f"\n\tField: {field}\n\tOperator: {operator}\n\tValue: {value}"
                            )
                Severity: Minor
                Found in fhir_kindling/fhir_query/base.py - About 35 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

                There are no issues that match your filters.

                Category
                Status