davidhuser/dhis2.py

View on GitHub
dhis2/utils.py

Summary

Maintainability
A
2 hrs
Test Coverage

Function import_response_ok has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
Open

def import_response_ok(response: dict) -> bool:
    """
    Assess DHIS2 response for import of events / trackedEntityInstances / metadata / dataValues.
    Useful if a `requests.Response` returns HTTP 200 OK but the response dict reports ignored values.
    :param response: The response of an import request.
Severity: Minor
Found in dhis2/utils.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 __init__ has 5 arguments (exceeds 4 allowed). Consider refactoring.
Open

    def __init__(self, status_ok: bool, imported: int, deleted: int, ignored: int, updated: int):
Severity: Minor
Found in dhis2/utils.py - About 35 mins to fix

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

    def search_auth_file(filename: str = "dish.json") -> str:
        """
        Search filename in
        - A) DHIS_HOME (env variable)
        - B) current user's home folder
    Severity: Minor
    Found in dhis2/utils.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 clean_obj has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
    Open

    def clean_obj(
        obj: Union[list, dict], remove: Union[Collection, str]
    ) -> Union[list, dict]:
        """
        Recursively remove keys from list/dict/dict-of-lists/list-of-keys/nested ...,
    Severity: Minor
    Found in dhis2/utils.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