migraf/fhir-kindling

View on GitHub
fhir_kindling/fhir_server/fhir_server.py

Summary

Maintainability
F
3 days
Test Coverage

File fhir_server.py has 862 lines of code (exceeds 250 allowed). Consider refactoring.
Open

import os
import re
from typing import Iterable, List, Union

import fhir.resources
Severity: Major
Found in fhir_kindling/fhir_server/fhir_server.py - About 2 days to fix

    FhirServer has 31 functions (exceeds 20 allowed). Consider refactoring.
    Open

    class FhirServer:
        def __init__(
            self,
            api_address: str,
            username: Union[str, None] = None,
    Severity: Minor
    Found in fhir_kindling/fhir_server/fhir_server.py - About 3 hrs to fix

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

          def __init__(
      Severity: Major
      Found in fhir_kindling/fhir_server/fhir_server.py - About 2 hrs to fix

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

            def transfer(
        Severity: Minor
        Found in fhir_kindling/fhir_server/fhir_server.py - About 45 mins to fix

          Function from_env has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
          Open

              def from_env(cls, no_auth: bool = False) -> "FhirServer":
                  api_address = _api_address_from_env()
                  server_type = os.getenv("FHIR_SERVER_TYPE")
          
                  if no_auth:
          Severity: Minor
          Found in fhir_kindling/fhir_server/fhir_server.py - About 45 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 add_all has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
          Open

              def add_all(
                  self,
                  resources: List[Union[Resource, FHIRAbstractModel, dict]],
                  batch_size: int = 1000,
                  display: bool = True,
          Severity: Minor
          Found in fhir_kindling/fhir_server/fhir_server.py - About 45 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 _setup_transport has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
          Open

              def _setup_transport(
                  self, async_transport: bool = False
              ) -> Union[RetryTransport, httpx.AsyncHTTPTransport, httpx.HTTPTransport]:
                  """Setup the transport for the httpx client if retryable methods or status codes are set
                  for the server the requests will be retried according to the configuration
          Severity: Minor
          Found in fhir_kindling/fhir_server/fhir_server.py - About 25 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