iterative/dvc

View on GitHub
dvc/output.py

Summary

Maintainability
F
5 days
Test Coverage

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

import logging
import os
from collections import defaultdict
from typing import TYPE_CHECKING, Dict, Optional, Set, Type
from urllib.parse import urlparse
Severity: Major
Found in dvc/output.py - About 2 days to fix

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

    class Output:
        IS_DEPENDENCY = False
    
        PARAM_PATH = "path"
        PARAM_CACHE = "cache"
    Severity: Major
    Found in dvc/output.py - About 7 hrs to fix

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

          def dumpd(self):
              ret = {**self.hash_info.to_dict(), **self.meta.to_dict()}
      
              if self.is_in_repo:
                  path = self.fs.path.as_posix(
      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 checkout has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
      Open

          def checkout(
              self,
              force=False,
              progress_callback=None,
              relink=False,
      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 __init__ has 12 arguments (exceeds 4 allowed). Consider refactoring.
      Open

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

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

            def get_used_objs(
                self, **kwargs
            ) -> Dict[Optional["ObjectDB"], Set["HashInfo"]]:
                """Return filtered set of used object IDs for this out."""
        
        
        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 9 arguments (exceeds 4 allowed). Consider refactoring.
        Open

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

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

              def __init__(
                  self,
                  stage,
                  path,
                  info=None,
          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 _merge_data has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
          Open

          def _merge_data(s_list):
              d = 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 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 load_from_pipeline has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
            Open

            def load_from_pipeline(stage, data, typ="outs"):
                if typ not in (
                    stage.PARAM_OUTS,
                    stage.PARAM_METRICS,
                    stage.PARAM_PLOTS,
            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 save has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
            Open

                def save(self):
                    if not self.exists:
                        raise self.DoesNotExistError(self)
            
                    if not self.isfile and not self.isdir:
            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 5 arguments (exceeds 4 allowed). Consider refactoring.
            Open

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

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

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

                  def get_obj(self, filter_info=None, **kwargs):
                      if self.obj:
                          obj = self.obj
                      elif self.hash_info:
                          try:
              Severity: Minor
              Found in dvc/output.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 verify_metric has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
              Open

                  def verify_metric(self):
                      if self.fs.protocol != "local":
                          raise DvcException(
                              f"verify metric is not supported for {self.protocol}"
                          )
              Severity: Minor
              Found in dvc/output.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 added, False if added else modified
              Severity: Major
              Found in dvc/output.py - About 30 mins to fix

                Avoid too many return statements within this function.
                Open

                        return {remote: self._named_obj_ids(obj)}
                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):
                          if not self.is_dir_checksum:
                              raise DvcException("cannot get dir cache for file checksum")
                  
                          obj = self.odb.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

                  There are no issues that match your filters.

                  Category
                  Status