zincware/ZnTrack

View on GitHub
zntrack/fields/zn/options.py

Summary

Maintainability
D
1 day
Test Coverage

File options.py has 430 lines of code (exceeds 250 allowed). Consider refactoring.
Open

"""Base classes for 'zntrack.<field>' fields."""

import dataclasses
import json
import logging
Severity: Minor
Found in zntrack/fields/zn/options.py - About 6 hrs to fix

    Function get_files has a Cognitive Complexity of 26 (exceeds 5 allowed). Consider refactoring.
    Open

        def get_files(self, instance) -> list:
            """Get the affected files of the respective Nodes."""
            files = []
    
            value = getattr(instance, self.name)
    Severity: Minor
    Found in zntrack/fields/zn/options.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 get_optional_dvc_cmd has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
    Open

        def get_optional_dvc_cmd(
            self, instance: "Node", git_only_repo: bool
        ) -> typing.List[list]:
            """Get the dvc command for this field."""
            nodes = getattr(instance, self.name)
    Severity: Minor
    Found in zntrack/fields/zn/options.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 __set__ has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
    Open

        def __set__(self, instance, value):
            """Disable the _graph_ in the value 'Node'."""
            if value is None:
                return super().__set__(instance, value)
    
    
    Severity: Minor
    Found in zntrack/fields/zn/options.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 _get_all_connections_and_instances has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
    Open

    def _get_all_connections_and_instances(value) -> list["Node"]:
        """Get Nodes from Connections and CombinedConnections."""
        connections = []
        stack = [value]
        while stack:
    Severity: Minor
    Found in zntrack/fields/zn/options.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 save has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

        def save(self, instance: "Node"):
            """Save the Node parameters to disk."""
            try:
                value = self.get_value_except_lazy(instance)
            except DataIsLazyError:
    Severity: Minor
    Found in zntrack/fields/zn/options.py - About 25 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