iterative/dvc

View on GitHub
dvc/repo/experiments/queue/base.py

Summary

Maintainability
D
2 days
Test Coverage

File base.py has 594 lines of code (exceeds 250 allowed). Consider refactoring.
Open

import os
from abc import ABC, abstractmethod
from collections.abc import Collection, Generator, Iterable, Mapping
from dataclasses import asdict, dataclass
from typing import TYPE_CHECKING, Any, NamedTuple, Optional, Union
Severity: Major
Found in dvc/repo/experiments/queue/base.py - About 1 day to fix

    Function match_queue_entry_by_name has a Cognitive Complexity of 23 (exceeds 5 allowed). Consider refactoring.
    Open

        def match_queue_entry_by_name(
            self,
            exp_names: Collection[str],
            *entries: Iterable[Union[QueueEntry, QueueDoneResult]],
        ) -> dict[str, Optional[QueueEntry]]:
    Severity: Minor
    Found in dvc/repo/experiments/queue/base.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

    BaseStashQueue has 26 functions (exceeds 20 allowed). Consider refactoring.
    Open

    class BaseStashQueue(ABC):
        """Naive Git-stash based experiment queue.
    
        Maps queued experiments to (Git) stash reflog entries.
        """
    Severity: Minor
    Found in dvc/repo/experiments/queue/base.py - About 3 hrs to fix

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

          def _update_params(self, params: dict[str, list[str]]):
              """Update param files with the provided `Hydra Override`_ patterns.
      
              Args:
                  params: Dict mapping paths to `Hydra Override`_ patterns,
      Severity: Minor
      Found in dvc/repo/experiments/queue/base.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 _stash_exp has 6 arguments (exceeds 4 allowed). Consider refactoring.
      Open

          def _stash_exp(
      Severity: Minor
      Found in dvc/repo/experiments/queue/base.py - About 45 mins to fix

        Function init_executor has 5 arguments (exceeds 4 allowed). Consider refactoring.
        Open

            def init_executor(
        Severity: Minor
        Found in dvc/repo/experiments/queue/base.py - About 35 mins to fix

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

              def status(self) -> list[dict[str, Any]]:
                  """Show the status of exp tasks in queue"""
                  from datetime import datetime
          
                  result: list[dict[str, Optional[str]]] = []
          Severity: Minor
          Found in dvc/repo/experiments/queue/base.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 active_repo has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
          Open

              def active_repo(self, name: str) -> "Repo":
                  """Return a Repo for the specified active experiment if it exists."""
                  from dvc.exceptions import DvcException
                  from dvc.repo import Repo
                  from dvc.repo.experiments.exceptions import (
          Severity: Minor
          Found in dvc/repo/experiments/queue/base.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