iterative/dvc

View on GitHub
dvc/output.py

Summary

Maintainability
F
6 days
Test Coverage

File output.py has 1212 lines of code (exceeds 250 allowed). Consider refactoring.
Open

import errno
import os
import posixpath
from collections import defaultdict
from contextlib import suppress
Severity: Major
Found in dvc/output.py - About 3 days to fix

    Function dumpd has a Cognitive Complexity of 34 (exceeds 5 allowed). Consider refactoring.
    Open

        def dumpd(self, **kwargs):  # noqa: C901, PLR0912
            from dvc.cachemgr import LEGACY_HASH_NAMES
    
            ret: dict[str, Any] = {}
            with_files = (
    Severity: Minor
    Found in dvc/output.py - About 5 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

    Output has 34 functions (exceeds 20 allowed). Consider refactoring.
    Open

    class Output:
        IS_DEPENDENCY = False
    
        PARAM_PATH = "path"
        PARAM_CACHE = "cache"
    Severity: Minor
    Found in dvc/output.py - About 4 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

        Function __init__ has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
        Open

            def __init__(  # noqa: PLR0913
                self,
                stage,
                path,
                info=None,
        Severity: Minor
        Found in dvc/output.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 __init__ has 29 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            def __init__(  # noqa: PLR0913
                self,
                stage,
                path,
                info=None,
        Severity: Minor
        Found in dvc/output.py - About 1 hr to fix

          Function _merge_data has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
          Open

          def _merge_data(s_list):
              d: dict[str, dict] = defaultdict(dict)
              for key in s_list:
                  if isinstance(key, str):
                      d[key].update({})
          Severity: Minor
          Found in dvc/output.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 loads_from has 8 arguments (exceeds 4 allowed). Consider refactoring.
          Open

          def loads_from(
          Severity: Major
          Found in dvc/output.py - About 1 hr to fix

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

                def commit(self, filter_info=None, relink=True) -> None:
                    if not self.exists:
                        raise self.DoesNotExistError(self)
            
                    assert self.hash_info
            Severity: Minor
            Found in dvc/output.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 _compute_meta_hash_info_from_files has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
            Open

                def _compute_meta_hash_info_from_files(self) -> None:
                    if self.files:
                        tree = Tree.from_list(self.files, hash_name=self.hash_name)
                        tree.digest(with_meta=True)
            
            
            Severity: Minor
            Found in dvc/output.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 checkout has 7 arguments (exceeds 4 allowed). Consider refactoring.
            Open

                def checkout(
            Severity: Major
            Found in dvc/output.py - About 50 mins to fix

              Function get_obj has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
              Open

                  def get_obj(
                      self, filter_info: Optional[str] = None, **kwargs
                  ) -> Optional["HashFile"]:
                      obj: Optional["HashFile"] = None
                      if self.obj:
              Severity: Minor
              Found in dvc/output.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

              Function transfer has 6 arguments (exceeds 4 allowed). Consider refactoring.
              Open

                  def transfer(
              Severity: Minor
              Found in dvc/output.py - About 45 mins to fix

                Function split_file_meta_from_cloud has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                Open

                def split_file_meta_from_cloud(entry: dict) -> dict:
                    if remote_name := entry.pop(Meta.PARAM_REMOTE, None):
                        remote_meta = {}
                        for key in (S3_PARAM_CHECKSUM, HDFS_PARAM_CHECKSUM, Meta.PARAM_VERSION_ID):
                            if value := entry.pop(key, None):
                Severity: Minor
                Found in dvc/output.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

                Function checkout has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                Open

                    def checkout(
                        self,
                        force: bool = False,
                        progress_callback: "Callback" = DEFAULT_CALLBACK,
                        relink: bool = False,
                Severity: Minor
                Found in dvc/output.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

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

                    def add(  # noqa: C901
                Severity: Minor
                Found in dvc/output.py - About 35 mins to fix

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

                      def _collect_used_dir_cache(
                  Severity: Minor
                  Found in dvc/output.py - About 35 mins to fix

                    Avoid too many return statements within this function.
                    Open

                            return self.fs.relpath(self.fs_path, self.repo.root_dir)
                    Severity: Major
                    Found in dvc/output.py - About 30 mins to fix

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

                          def get_dir_cache(self, **kwargs) -> Optional["Tree"]:
                              if not self.is_dir_checksum:
                                  raise DvcException("cannot get dir cache for file checksum")
                      
                              obj = self.cache.get(self.hash_info.value)
                      Severity: Minor
                      Found in dvc/output.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 _collect_used_dir_cache has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                      Open

                          def _collect_used_dir_cache(
                              self, remote=None, force=False, jobs=None, filter_info=None
                          ) -> Optional["Tree"]:
                              """Fetch dir cache and return used object IDs for this out."""
                      
                      
                      Severity: Minor
                      Found in dvc/output.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