iterative/dvc

View on GitHub
dvc/stage.py

Summary

Maintainability
B
6 hrs
Test Coverage

File stage.py has 709 lines of code (exceeds 250 allowed). Consider refactoring.
Wontfix

from __future__ import unicode_literals

from dvc.utils.compat import str

import copy
Severity: Major
Found in dvc/stage.py - About 1 day to fix

    Stage has 49 functions (exceeds 20 allowed). Consider refactoring.
    Wontfix

    class Stage(object):
        STAGE_FILE = "Dvcfile"
        STAGE_FILE_SUFFIX = ".dvc"
    
        PARAM_MD5 = "md5"
    Severity: Minor
    Found in dvc/stage.py - About 6 hrs to fix

      Function run has a Cognitive Complexity of 27 (exceeds 5 allowed). Consider refactoring.
      Open

          def run(self, dry=False, no_commit=False, force=False):
              if (self.cmd or self.is_import) and not self.locked and not dry:
                  self.remove_outs(ignore_remove=False, force=False)
      
              if self.locked:
      Severity: Minor
      Found in dvc/stage.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

      Function create has a Cognitive Complexity of 23 (exceeds 5 allowed). Consider refactoring.
      Wontfix

          def create(repo, **kwargs):
      
              wdir = kwargs.get("wdir", None)
              cwd = kwargs.get("cwd", None)
              fname = kwargs.get("fname", None)
      Severity: Minor
      Found in dvc/stage.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

      Function check_can_commit has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
      Wontfix

          def check_can_commit(self, force):
              changed_deps = self._changed_entries(self.deps)
              changed_outs = self._changed_entries(self.outs)
      
              if changed_deps or changed_outs or self.changed_md5():
      Severity: Minor
      Found in dvc/stage.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 11 arguments (exceeds 4 allowed). Consider refactoring.
      Open

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

        Function status has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
        Wontfix

            def status(self):
                ret = []
        
                if not self.locked:
                    deps_status = self._status(self.deps)
        Severity: Minor
        Found in dvc/stage.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 False
        Severity: Major
        Found in dvc/stage.py - About 30 mins to fix

          Function _changed_deps has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
          Wontfix

              def _changed_deps(self):
                  if self.locked:
                      return False
          
                  if self.is_callback:
          Severity: Minor
          Found in dvc/stage.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 _run has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
          Open

              def _run(self):
                  self._check_missing_deps()
          
                  kwargs = {"cwd": self.wdir, "env": fix_env(None), "close_fds": True}
          
          
          Severity: Minor
          Found in dvc/stage.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

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

          class StageFileIsNotDvcFileError(DvcException):
              def __init__(self, fname):
                  msg = "'{}' is not a DVC-file".format(fname)
          
                  sname = fname + Stage.STAGE_FILE_SUFFIX
          Severity: Major
          Found in dvc/stage.py and 1 other location - About 3 hrs to fix
          dvc/stage.py on lines 43..51

          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 72.

          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.
          Wontfix

          class StageFileDoesNotExistError(DvcException):
              def __init__(self, fname):
                  msg = "'{}' does not exist.".format(fname)
          
                  sname = fname + Stage.STAGE_FILE_SUFFIX
          Severity: Major
          Found in dvc/stage.py and 1 other location - About 3 hrs to fix
          dvc/stage.py on lines 60..68

          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 72.

          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.
          Wontfix

                  for dep in self.deps:
                      status = dep.status()
                      if status:
                          logger.warning(
                              "Dependency '{dep}' of '{stage}' changed because it is "
          Severity: Major
          Found in dvc/stage.py and 1 other location - About 2 hrs to fix
          dvc/stage.py on lines 268..277

          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 59.

          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.
          Wontfix

                  for out in self.outs:
                      status = out.status()
                      if status:
                          logger.warning(
                              "Output '{out}' of '{stage}' changed because it is "
          Severity: Major
          Found in dvc/stage.py and 1 other location - About 2 hrs to fix
          dvc/stage.py on lines 254..263

          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 59.

          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 6 locations. Consider refactoring.
          Wontfix

          class StageFileAlreadyExistsError(DvcException):
              def __init__(self, relpath):
                  msg = "stage '{}' already exists".format(relpath)
                  super(StageFileAlreadyExistsError, self).__init__(msg)
          Severity: Major
          Found in dvc/stage.py and 5 other locations - About 50 mins to fix
          dvc/dependency/base.py on lines 6..9
          dvc/dependency/base.py on lines 12..15
          dvc/output/base.py on lines 18..21
          dvc/output/base.py on lines 24..27
          dvc/output/base.py on lines 30..33

          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 36.

          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 3 locations. Consider refactoring.
          Wontfix

          class StagePathNotFoundError(DvcException):
              def __init__(self, path):
                  msg = "stage working or file path '{}' does not exist"
                  super(StagePathNotFoundError, self).__init__(msg.format(path))
          Severity: Major
          Found in dvc/stage.py and 2 other locations - About 50 mins to fix
          dvc/stage.py on lines 76..79
          dvc/stage.py on lines 88..91

          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 36.

          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 3 locations. Consider refactoring.
          Wontfix

          class StagePathNotDirectoryError(DvcException):
              def __init__(self, path):
                  msg = "stage working or file path '{}' is not directory"
                  super(StagePathNotDirectoryError, self).__init__(msg.format(path))
          Severity: Major
          Found in dvc/stage.py and 2 other locations - About 50 mins to fix
          dvc/stage.py on lines 76..79
          dvc/stage.py on lines 82..85

          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 36.

          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 3 locations. Consider refactoring.
          Wontfix

          class StagePathOutsideError(DvcException):
              def __init__(self, path):
                  msg = "stage working or file path '{}' is outside of dvc repo"
                  super(StagePathOutsideError, self).__init__(msg.format(path))
          Severity: Major
          Found in dvc/stage.py and 2 other locations - About 50 mins to fix
          dvc/stage.py on lines 82..85
          dvc/stage.py on lines 88..91

          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 36.

          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.
          Wontfix

              @staticmethod
              def _check_isfile(repo, fname):
                  if not repo.tree.isfile(fname):
                      raise StageFileIsNotDvcFileError(fname)
          Severity: Minor
          Found in dvc/stage.py and 1 other location - About 30 mins to fix
          dvc/stage.py on lines 580..583

          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 32.

          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.
          Wontfix

              @staticmethod
              def _check_file_exists(repo, fname):
                  if not repo.tree.exists(fname):
                      raise StageFileDoesNotExistError(fname)
          Severity: Minor
          Found in dvc/stage.py and 1 other location - About 30 mins to fix
          dvc/stage.py on lines 585..588

          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 32.

          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

          There are no issues that match your filters.

          Category
          Status