iterative/dvc

View on GitHub
dvc/utils/__init__.py

Summary

Maintainability
A
3 hrs
Test Coverage

File __init__.py has 271 lines of code (exceeds 250 allowed). Consider refactoring.
Wontfix

"""Helpers for other modules."""

import hashlib
import json
import os
Severity: Minor
Found in dvc/utils/__init__.py - About 2 hrs to fix

    Function parse_target has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
    Open

    def parse_target(
        target: str, default: Optional[str] = None, isa_glob: bool = False
    ) -> tuple[Optional[str], Optional[str]]:
        from dvc.dvcfile import LOCK_FILE, PROJECT_FILE, is_valid_filename
        from dvc.exceptions import DvcException
    Severity: Minor
    Found in dvc/utils/__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 fix_env has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
    Wontfix

    def fix_env(env=None):
        """Fix env variables modified by PyInstaller [1] and pyenv [2].
        [1] http://pyinstaller.readthedocs.io/en/stable/runtime-information.html
        [2] https://github.com/pyenv/pyenv/issues/985
        """
    Severity: Minor
    Found in dvc/utils/__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 resolve_paths has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
    Open

    def resolve_paths(repo, out, always_local=False):
        from urllib.parse import urlparse
    
        from dvc.dvcfile import DVC_FILE_SUFFIX
        from dvc.exceptions import DvcException
    Severity: Minor
    Found in dvc/utils/__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

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

    def error_handler(func):
        def wrapper(*args, **kwargs):
            onerror = kwargs.get("onerror", None)
            result = {}
    
    
    Severity: Minor
    Found in dvc/utils/__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

    Avoid too many return statements within this function.
    Open

        return path or default, name
    Severity: Major
    Found in dvc/utils/__init__.py - About 30 mins to fix

      There are no issues that match your filters.

      Category
      Status