iterative/dvc

View on GitHub

Showing 547 of 589 total issues

Function _diff has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
Open

def _diff(
    old: "DataIndex",
    new: "DataIndex",
    *,
    granular: bool = False,
Severity: Minor
Found in dvc/repo/data.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 remove_tasks has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
Open

def remove_tasks(  # noqa: C901, PLR0912
    celery_queue: "LocalCeleryQueue",
    queue_entries: Iterable["QueueEntry"],
):
    """Remove tasks from task queue.
Severity: Minor
Found in dvc/repo/experiments/queue/remove.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 pull has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
Open

def pull(  # noqa: C901
    repo,
    git_remote: str,
    exp_names: Optional[Union[Iterable[str], str]] = None,
    all_commits=False,
Severity: Minor
Found in dvc/repo/experiments/pull.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 describe has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
Open

def describe(
    scm: "Git",
    revs: Iterable[str],
    logger,
    refs: Optional[Iterable[str]] = None,
Severity: Minor
Found in dvc/repo/experiments/utils.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 _calculate_column_widths has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
Open

    def _calculate_column_widths(
        self, console: "Console", options: "ConsoleOptions"
    ) -> list[int]:
        """Calculate the widths of each column, including padding, not
        including borders.
Severity: Minor
Found in dvc/utils/table.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 yappi_profile has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
Open

def yappi_profile(
    path: Optional[Union[Callable[[], str], str]] = None,
    wall_clock: Optional[bool] = True,
    separate_threads: Optional[bool] = False,
):
Severity: Minor
Found in dvc/_debug.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

BaseExecutor has 24 functions (exceeds 20 allowed). Consider refactoring.
Open

class BaseExecutor(ABC):
    """Base class for executing experiments in parallel.

    Parameters:
        root_dir: Path to SCM root.
Severity: Minor
Found in dvc/repo/experiments/executor/base.py - About 2 hrs to fix

    File data.py has 277 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    from contextlib import _GeneratorContextManager as GCM
    from contextlib import contextmanager
    from typing import Any, Optional
    
    from funcy import reraise
    Severity: Minor
    Found in dvc/api/data.py - About 2 hrs to fix

      File worktree.py has 276 lines of code (exceeds 250 allowed). Consider refactoring.
      Open

      from collections.abc import Iterable
      from functools import partial
      from typing import TYPE_CHECKING, Any, Optional, Union
      
      from funcy import first
      Severity: Minor
      Found in dvc/repo/worktree.py - About 2 hrs to fix

        Function commit_2_to_3 has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
        Open

        def commit_2_to_3(repo: "Repo", dry: bool = False):
            """Force-commit all legacy outputs to use DVC 3.0 hashes."""
            from dvc.dvcfile import ProjectFile
            from dvc.ui import ui
        
        
        Severity: Minor
        Found in dvc/repo/commit.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 _merge_params has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
        Open

        def _merge_params(s_list) -> dict[str, list[str]]:
            d = defaultdict(list)
            default_file = ParamsDependency.DEFAULT_PARAMS_FILE
        
            # figure out completely tracked params file, and ignore specific keys
        Severity: Minor
        Found in dvc/dependency/__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

        Function __pretty_exc__ has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
        Open

            def __pretty_exc__(self, **kwargs: Any) -> None:  # noqa: C901
                from ruamel.yaml.error import MarkedYAMLError
        
                exc = self.exc.__cause__
        
        
        Severity: Minor
        Found in dvc/utils/strictyaml.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 _show_diff has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
        Open

            def _show_diff(diff, hide_missing=False):
                """
                Given a diff structure, generate a string of paths separated
                by new lines and grouped together by their state.
        
        
        Severity: Minor
        Found in dvc/commands/diff.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

        Similar blocks of code found in 2 locations. Consider refactoring.
        Open

        def add_parser(subparsers, parent_parser):
            ROOT_HELP = "Return the relative path to the root of the DVC project."
            root_parser = subparsers.add_parser(
                "root",
                parents=[parent_parser],
        Severity: Major
        Found in dvc/commands/root.py and 1 other location - About 2 hrs to fix
        dvc/commands/experiments/clean.py on lines 15..24

        Duplicated Code

        Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

        Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

        When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

        Tuning

        This issue has a mass of 56.

        We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

        The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

        If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

        See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

        Refactorings

        Further Reading

        Similar blocks of code found in 2 locations. Consider refactoring.
        Open

        def add_parser(experiments_subparsers, parent_parser):
            EXPERIMENTS_CLEAN_HELP = "Cleanup experiments temporary internal files."
            experiments_clean_parser = experiments_subparsers.add_parser(
                "clean",
                parents=[parent_parser],
        Severity: Major
        Found in dvc/commands/experiments/clean.py and 1 other location - About 2 hrs to fix
        dvc/commands/root.py on lines 19..28

        Duplicated Code

        Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

        Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

        When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

        Tuning

        This issue has a mass of 56.

        We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

        The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

        If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

        See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

        Refactorings

        Further Reading

        Function resolve_name has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
        Open

        def resolve_name(
            scm: "Git",
            exp_names: Union[Iterable[str], str],
            git_remote: Optional[str] = None,
        ) -> dict[str, Optional[ExpRefInfo]]:
        Severity: Minor
        Found in dvc/repo/experiments/utils.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 _reproduce has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
        Open

        def _reproduce(
            stages: list["Stage"],
            graph: Optional["DiGraph"] = None,
            force_downstream: bool = False,
            on_error: str = "fail",
        Severity: Minor
        Found in dvc/repo/reproduce.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 _build_tree_structure has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
        Open

        def _build_tree_structure(
            entries, with_color=False, with_size=False, with_hash=False, _depth=0, _prefix=""
        ):
            rows = []
            fmt = _get_formatter(with_color)
        Severity: Minor
        Found in dvc/commands/ls/__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 path_info.py has 267 lines of code (exceeds 250 allowed). Consider refactoring.
        Open

        import os
        import pathlib
        import posixpath
        import sys
        from typing import Callable, ClassVar
        Severity: Minor
        Found in dvc/testing/path_info.py - About 2 hrs to fix

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

              def __init__(  # noqa: PLR0913
          Severity: Major
          Found in dvc/output.py - About 2 hrs to fix
            Severity
            Category
            Status
            Source
            Language