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
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 = []
- Read upRead up
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.
"""
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()
- Read upRead up
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_refs_for_generator
has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring. Open
def _get_refs_for_generator(
self, generator: DataSetResourceGenerator, result: dict
) -> dict:
"""Get the references resources for a generator from the results and insert a reference to them into
the reference field of the generator
- Read upRead up
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_generator_to_graph
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
def _add_generator_to_graph(self, generator: DataSetResourceGenerator):
self._graph.add_node(generator.name, generator=generator)
if generator.depends_on:
if isinstance(generator.depends_on, str):
self._graph.add_edge(
- Read upRead up
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_time_series
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
def _generate_time_series(self):
resources = self.generator.generate(generate_ids=True, as_dict=True)
if self.references:
# insert the references
for r in resources:
- Read upRead up
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_and_reference
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
def _validate_depends_and_reference(
self,
depends_on: Union[str, List[str]],
reference_field: Union[str, List[str], None],
):
- Read upRead up
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 10 (exceeds 5 allowed). Consider refactoring. Open
def generate(self, display: bool = False) -> DataSet:
"""
Generate a dataset of FHIR resources according to the given conditions
Args:
- Read upRead up
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 5 arguments (exceeds 4 allowed). Consider refactoring. Open
def __init__(
Function add_resource_generator
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
def add_resource_generator(
Function generate
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def generate(self):
# generate based on the likelihood
if self.likelihood < 1.0:
if random.random() > self.likelihood:
return None
- Read upRead up
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_resource_generator
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def add_resource_generator(
self,
resource_generator: BaseGenerator,
name: str,
depends_on: Union[str, List[str]] = "base",
- Read upRead up
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"