migraf/fhir-kindling

View on GitHub

Showing 93 of 93 total issues

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

    File dataset.py has 457 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    import random
    from typing import Dict, List, Optional, Type, Union
    from uuid import uuid4
    
    import matplotlib.pyplot as plt
    Severity: Minor
    Found in fhir_kindling/generators/dataset.py - About 7 hrs 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

        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 _resolve_xml_pagination has a Cognitive Complexity of 23 (exceeds 5 allowed). Consider refactoring.
          Open

              def _resolve_xml_pagination(self, server_response: httpx.Response) -> str:
                  # parse the xml response and extract the initial entries
                  initial_response = xmltodict.parse(server_response.text)
                  entries = initial_response["Bundle"].get("entry")
          
          
          Severity: Minor
          Found in fhir_kindling/fhir_query/query_sync.py - About 3 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

          File bench.py has 300 lines of code (exceeds 250 allowed). Consider refactoring.
          Open

          import os
          import time
          from datetime import datetime
          from typing import Any, List, Tuple, Union
          
          
          Severity: Minor
          Found in fhir_kindling/benchmark/bench.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

            File query_parameters.py has 281 lines of code (exceeds 250 allowed). Consider refactoring.
            Open

            from abc import ABC
            from enum import Enum
            from typing import List, Optional, Tuple, Union
            
            from pydantic import BaseModel, root_validator, validator
            Severity: Minor
            Found in fhir_kindling/fhir_query/query_parameters.py - About 2 hrs to fix

              Function _resolve_json_pagination has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
              Open

                  def _resolve_json_pagination(
                      self,
                      initial_response: httpx.Response,
                      page_callback: Union[
                          Callable[[List[FHIRAbstractModel]], Any], Callable[[], Any], None
              Severity: Minor
              Found in fhir_kindling/fhir_query/query_sync.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 _setup has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
              Open

                  def _setup(
                      self,
                      queries: Union[List[Tuple[str, Union[str, FhirQueryParameters]]], None] = None,
                      steps: List[Union[str, BenchmarkOperations]] = None,
                  ):
              Severity: Minor
              Found in fhir_kindling/benchmark/bench.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 __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 _get_required_reference has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
                Open

                    def _get_required_reference(
                        resource: Union[FHIRResourceModel, Type[FHIRAbstractModel]]
                    ) -> str:
                        fields = get_resource_fields(resource)
                        required_fields = []
                Severity: Minor
                Found in fhir_kindling/generators/dataset.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 flatten_dict has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
                Open

                def flatten_dict(
                    d, parent_key: str = "", sep: str = "_", keys: List[str] = None
                ) -> dict:
                    """
                    Flatten a nested dictionary into a single level dictionary.
                Severity: Minor
                Found in fhir_kindling/serde/flatten.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 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

                DatasetGenerator has 21 functions (exceeds 20 allowed). Consider refactoring.
                Open

                class DatasetGenerator:
                
                    """
                    Generates a dataset of FHIR resources.
                    """
                Severity: Minor
                Found in fhir_kindling/generators/dataset.py - About 2 hrs to fix

                  Function make_transaction_entry has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
                  Open

                  def make_transaction_entry(
                      method: Union[TransactionMethod, str],
                      url: str = None,
                      resource: Union[Resource, dict] = None,
                  ) -> BundleEntry:
                  Severity: Minor
                  Found in fhir_kindling/fhir_server/transactions.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 generate has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
                  Open

                      def generate(
                          self,
                          references: bool = False,
                          generate_ids: bool = False,
                          as_dict: bool = False,
                  Severity: Minor
                  Found in fhir_kindling/generators/patient.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 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

                  Function _validate_depends has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
                  Open

                      def _validate_depends(
                          self,
                          depends_on: Union[str, List[str]],
                      ):
                          graph = self.graph()
                  Severity: Minor
                  Found in fhir_kindling/generators/dataset.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_from_graph_node has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
                  Open

                  def _resource_from_graph_node(graph: nx.DiGraph, node: str) -> FHIRAbstractModel:
                      """
                      Get a resource from a graph node.
                  
                      Args:
                  Severity: Minor
                  Found in fhir_kindling/fhir_server/transfer.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

                  Severity
                  Category
                  Status
                  Source
                  Language