openimis/openimis-be-api_fhir_py

View on GitHub
api_fhir/models/__init__.py

Summary

Maintainability
C
1 day
Test Coverage

Function toDict has a Cognitive Complexity of 23 (exceeds 5 allowed). Consider refactoring.
Open

    def toDict(self):
        retval = dict()

        if isinstance(self, Resource):
            retval['resourceType'] = self.__class__.__name__
Severity: Minor
Found in api_fhir/models/__init__.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

Function _fromDict has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring.
Open

    def _fromDict(self, object_dict):
        for attr, obj in object_dict.items():

            prop, prop_type = self._get_property_details_for_name(attr)
            value = None
Severity: Minor
Found in api_fhir/models/__init__.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 __init__.py has 251 lines of code (exceeds 250 allowed). Consider refactoring.
Open

import inspect
import json
import sys

import math
Severity: Minor
Found in api_fhir/models/__init__.py - About 2 hrs to fix

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

        def __set__(self, instance, value):
            if self.definition.count_max > 1:
                if isinstance(value, list):
                    instance._values.setdefault(self.definition.name, PropertyList(self.definition))
                    del instance._values[self.definition.name][:]
    Severity: Minor
    Found in api_fhir/models/__init__.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 5 arguments (exceeds 4 allowed). Consider refactoring.
    Open

        def __init__(self, name, property_type, count_max=1, count_min=0, required=False):
    Severity: Minor
    Found in api_fhir/models/__init__.py - About 35 mins to fix

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

          def __init__(self, name, property_type, count_max=1, count_min=0, required=False):
      Severity: Minor
      Found in api_fhir/models/__init__.py - About 35 mins to fix

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

            def validate_type(self, value):
                if value is not None:
                    local_type = self.eval_property_type()
                    if local_type is FHIRDate and not FHIRDate.validate_type(value):
                        raise ValueError(gettext('Value "{}" is not a valid value of FHIRDate').format(value))
        Severity: Minor
        Found in api_fhir/models/__init__.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