CIMAC-CIDC/cidc-schemas

View on GitHub
cidc_schemas/migrations.py

Summary

Maintainability
C
1 day
Test Coverage
A
97%

File migrations.py has 305 lines of code (exceeds 250 allowed). Consider refactoring.
Open

from copy import deepcopy
from typing import NamedTuple, Dict

from .prism.core import _ENCRYPTED_FIELD_LEN, _encrypt

Severity: Minor
Found in cidc_schemas/migrations.py - About 3 hrs to fix

    Function upgrade has a Cognitive Complexity of 28 (exceeds 10 allowed). Consider refactoring.
    Open

        def upgrade(cls, metadata: dict, *args, **kwargs) -> MigrationResult:
            # these are removal, so cannot downgrade later
            metadata.pop("collection_event_list", None)
    
            for partic in metadata.get("participants", []):
    Severity: Minor
    Found in cidc_schemas/migrations.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 downgrade has a Cognitive Complexity of 24 (exceeds 10 allowed). Consider refactoring.
    Open

        def downgrade(cls, metadata: dict, *args, **kwargs) -> MigrationResult:
            if "cytof" in metadata.get("assays", {}):
                for batch in metadata["assays"]["cytof"]:
                    for record in batch["records"]:
                        if "concatenation_version" in record["input_files"]:
    Severity: Minor
    Found in cidc_schemas/migrations.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 upgrade has a Cognitive Complexity of 23 (exceeds 10 allowed). Consider refactoring.
    Open

        def upgrade(cls, metadata: dict, *args, **kwargs) -> MigrationResult:
    
            not_reported = _encrypt("Not reported")
    
            for p in metadata.get("participants", []):
    Severity: Minor
    Found in cidc_schemas/migrations.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

    There are no issues that match your filters.

    Category
    Status