migraf/fhir-kindling

View on GitHub
fhir_kindling/fhir_query/query_parameters.py

Summary

Maintainability
B
6 hrs
Test Coverage

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

        def check_value(cls, v, values):
            if isinstance(v, list):
                if values["operator"] not in [QueryOperators.in_, QueryOperators.not_in]:
                    raise ValueError(
                        "List values can only be used with the 'in' and 'not_in' operator."
    Severity: Minor
    Found in fhir_kindling/fhir_query/query_parameters.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 from_query_string has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
    Open

        def from_query_string(cls, query_string: str) -> "FhirQueryParameters":
            # split resource and query parameters
            resource, query = query_string.split("?")
    
            # clean up and validate resource
    Severity: Minor
    Found in fhir_kindling/fhir_query/query_parameters.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 to_query_string has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

        def to_query_string(self) -> str:
            """
            Converts the parameters to a query string that can be used with a fhir server's REST API
            Returns:
            """
    Severity: Minor
    Found in fhir_kindling/fhir_query/query_parameters.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 parse_parameter_value has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
    Open

    def parse_parameter_value(
        url_value: str,
    ) -> Tuple[QueryOperators, Union[int, float, bool, str, list]]:
        """
        Parse a query parameter value for operators and value types
    Severity: Minor
    Found in fhir_kindling/fhir_query/query_parameters.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

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

        def from_url_param(cls, url_string: str) -> "IncludeParameter":
            field, param = url_string.split("=")
            split_field = field.split(":")
            if len(split_field) == 2:
                reverse = split_field[0] == "_revinclude"
    Severity: Minor
    Found in fhir_kindling/fhir_query/query_parameters.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