iterative/dvc

View on GitHub

Showing 419 of 497 total issues

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

import itertools
import logging
import os
from concurrent.futures import ThreadPoolExecutor
from copy import copy
Severity: Minor
Found in dvc/objects/db/base.py - About 4 hrs to fix

    File data_sync.py has 365 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    import argparse
    import logging
    
    from dvc.command import completion
    from dvc.command.base import CmdBase, append_doc_link
    Severity: Minor
    Found in dvc/command/data_sync.py - About 4 hrs to fix

      Function _collect_experiment_commit has a Cognitive Complexity of 32 (exceeds 5 allowed). Consider refactoring.
      Open

      def _collect_experiment_commit(
          repo, exp_rev, stash=False, sha_only=True, param_deps=False
      ):
          res = defaultdict(dict)
          for rev in repo.brancher(revs=[exp_rev]):
      Severity: Minor
      Found in dvc/repo/experiments/show.py - About 4 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 used_objs has a Cognitive Complexity of 31 (exceeds 5 allowed). Consider refactoring.
      Open

          def used_objs(
              self,
              targets=None,
              all_branches=False,
              with_deps=False,
      Severity: Minor
      Found in dvc/repo/__init__.py - About 4 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

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

              self.repo.gc(
                  all_branches=self.args.all_branches,
                  all_tags=self.args.all_tags,
                  all_commits=self.args.all_commits,
                  all_experiments=self.args.all_experiments,
      Severity: Major
      Found in dvc/command/gc.py and 1 other location - About 4 hrs to fix
      dvc/command/data_sync.py on lines 57..67

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

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

                  processed_files_count = self.repo.push(
                      targets=self.args.targets,
                      jobs=self.args.jobs,
                      remote=self.args.remote,
                      all_branches=self.args.all_branches,
      Severity: Major
      Found in dvc/command/data_sync.py and 1 other location - About 4 hrs to fix
      dvc/command/gc.py on lines 50..60

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

      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

      Function push_refspec has a Cognitive Complexity of 28 (exceeds 5 allowed). Consider refactoring.
      Open

          def push_refspec(
              self,
              url: str,
              src: Optional[str],
              dest: str,
      Severity: Minor
      Found in dvc/scm/git/backend/dulwich.py - About 4 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

      File dvcfile.py has 333 lines of code (exceeds 250 allowed). Consider refactoring.
      Open

      import collections
      import contextlib
      import logging
      import os
      from typing import TYPE_CHECKING, Any, Union
      Severity: Minor
      Found in dvc/dvcfile.py - About 4 hrs to fix

        GDriveFileSystem has 31 functions (exceeds 20 allowed). Consider refactoring.
        Open

        class GDriveFileSystem(BaseFileSystem):  # pylint:disable=abstract-method
            scheme = Schemes.GDRIVE
            PATH_CLS = GDriveURLInfo
            PARAM_CHECKSUM = "checksum"
            REQUIRES = {"pydrive2": "pydrive2"}
        Severity: Minor
        Found in dvc/fs/gdrive.py - About 3 hrs to fix

          File repo.py has 326 lines of code (exceeds 250 allowed). Consider refactoring.
          Open

          import logging
          import os
          import stat
          import threading
          from contextlib import suppress
          Severity: Minor
          Found in dvc/fs/repo.py - About 3 hrs to fix

            File __init__.py has 323 lines of code (exceeds 250 allowed). Consider refactoring.
            Open

            import logging
            from collections.abc import Mapping, Sequence
            from copy import deepcopy
            from typing import (
                TYPE_CHECKING,
            Severity: Minor
            Found in dvc/parsing/__init__.py - About 3 hrs to fix

              File ignore.py has 322 lines of code (exceeds 250 allowed). Consider refactoring.
              Open

              import logging
              import os
              import re
              from collections import namedtuple
              from itertools import groupby, takewhile
              Severity: Minor
              Found in dvc/ignore.py - About 3 hrs to fix

                File stage.py has 320 lines of code (exceeds 250 allowed). Consider refactoring.
                Open

                import argparse
                import logging
                from itertools import chain, filterfalse
                from typing import TYPE_CHECKING, Dict, Iterable, List
                
                
                Severity: Minor
                Found in dvc/command/stage.py - About 3 hrs to fix

                  Function get_ref has a Cognitive Complexity of 25 (exceeds 5 allowed). Consider refactoring.
                  Open

                      def get_ref(self, name: str, follow: bool = True) -> Optional[str]:
                          from git.exc import GitCommandError
                  
                          if name == "HEAD":
                              try:
                  Severity: Minor
                  Found in dvc/scm/git/backend/gitpython.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

                  SSHConnection has 29 functions (exceeds 20 allowed). Consider refactoring.
                  Open

                  class SSHConnection:
                      def __init__(self, host, *args, **kwargs):
                          logger.debug(
                              "Establishing ssh connection with '{host}' "
                              "through port '{port}' as user '{username}'".format(
                  Severity: Minor
                  Found in dvc/fs/ssh/connection.py - About 3 hrs to fix

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

                    def _output_paths(repo, repo_fs, targets):
                        from dvc.fs.local import LocalFileSystem
                    
                        on_working_fs = isinstance(repo.fs, LocalFileSystem)
                    
                    
                    Severity: Minor
                    Found in dvc/repo/diff.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

                    ObjectDB has 27 functions (exceeds 20 allowed). Consider refactoring.
                    Open

                    class ObjectDB:
                    
                        DEFAULT_VERIFY = False
                        DEFAULT_CACHE_TYPES = ["copy"]
                        CACHE_MODE: Optional[int] = None
                    Severity: Minor
                    Found in dvc/objects/db/base.py - About 3 hrs to fix

                      Function add has a Cognitive Complexity of 22 (exceeds 5 allowed). Consider refactoring.
                      Open

                          def add(self, paths: Union[str, Iterable[str]], update=False):
                              from dvc.utils.fs import walk_files
                      
                              assert paths or update
                      
                      
                      Severity: Minor
                      Found in dvc/scm/git/backend/dulwich.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

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

                      class TabularData(MutableSequence[Sequence["CellT"]]):
                          def __init__(self, columns: Sequence[str], fill_value: str = ""):
                              self._columns: Dict[str, Column] = {name: Column() for name in columns}
                              self._keys: List[str] = list(columns)
                              self._fill_value = fill_value
                      Severity: Minor
                      Found in dvc/compare.py - About 3 hrs to fix

                        Function checkout_index has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring.
                        Open

                            def checkout_index(
                                self,
                                paths: Optional[Iterable[str]] = None,
                                force: bool = False,
                                ours: bool = False,
                        Severity: Minor
                        Found in dvc/scm/git/backend/pygit2.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

                        Severity
                        Category
                        Status
                        Source
                        Language