iterative/dvc

View on GitHub
dvc/repo/__init__.py

Summary

Maintainability
C
1 day
Test Coverage

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

import os
from collections import defaultdict
from collections.abc import Iterable
from contextlib import AbstractContextManager, contextmanager
from functools import wraps
Severity: Major
Found in dvc/repo/__init__.py - About 1 day to fix

    Repo has 38 functions (exceeds 20 allowed). Consider refactoring.
    Wontfix

    class Repo:
        DVC_DIR = ".dvc"
    
        from dvc.repo.add import add  # type: ignore[misc]
        from dvc.repo.checkout import checkout  # type: ignore[misc]
    Severity: Minor
    Found in dvc/repo/__init__.py - About 5 hrs to fix

      Function used_objs has 17 arguments (exceeds 4 allowed). Consider refactoring.
      Open

          def used_objs(  # noqa: PLR0913
      Severity: Major
      Found in dvc/repo/__init__.py - About 2 hrs to fix

        Function __init__ has 46 lines of code (exceeds 25 allowed). Consider refactoring.
        Wontfix

            def __init__(  # noqa: PLR0915, PLR0913
                self,
                root_dir: Optional[str] = None,
                fs: Optional["FileSystem"] = None,
                rev: Optional[str] = None,
        Severity: Minor
        Found in dvc/repo/__init__.py - About 1 hr to fix

          Function _get_repo_dirs has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
          Open

              def _get_repo_dirs(
                  self,
                  root_dir: Optional[str] = None,
                  fs: Optional["FileSystem"] = None,
                  uninitialized: bool = False,
          Severity: Minor
          Found in dvc/repo/__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 __init__ has 12 arguments (exceeds 4 allowed). Consider refactoring.
          Open

              def __init__(  # noqa: PLR0915, PLR0913
          Severity: Major
          Found in dvc/repo/__init__.py - About 1 hr to fix

            Function used_objs has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
            Open

                def used_objs(  # noqa: PLR0913
                    self,
                    targets=None,
                    all_branches=False,
                    with_deps=False,
            Severity: Minor
            Found in dvc/repo/__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 find_root has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
            Open

                def find_root(cls, root=None, fs=None) -> str:
                    from dvc.fs import LocalFileSystem, localfs
            
                    fs = fs or localfs
                    root = root or os.curdir
            Severity: Minor
            Found in dvc/repo/__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 __init__ has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
            Open

                def __init__(  # noqa: PLR0915, PLR0913
                    self,
                    root_dir: Optional[str] = None,
                    fs: Optional["FileSystem"] = None,
                    rev: Optional[str] = None,
            Severity: Minor
            Found in dvc/repo/__init__.py - About 45 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 None
            Severity: Major
            Found in dvc/repo/__init__.py - About 30 mins to fix

              Function find_outs_by_path has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
              Open

                  def find_outs_by_path(self, path, outs=None, recursive=False, strict=True):
                      # using `outs_graph` to ensure graph checks are run
                      outs = outs or self.index.outs_graph
              
                      abs_path = self.fs.abspath(path)
              Severity: Minor
              Found in dvc/repo/__init__.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

              Function site_cache_dir has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
              Open

                  def site_cache_dir(self) -> str:
                      import getpass
                      import hashlib
              
                      from dvc.dirs import site_cache_dir
              Severity: Minor
              Found in dvc/repo/__init__.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