iterative/dvc

View on GitHub

Showing 536 of 578 total issues

Function _merge_push_meta has a Cognitive Complexity of 24 (exceeds 5 allowed). Consider refactoring.
Open

def _merge_push_meta(  # noqa: C901
    out: "Output",
    index: Union["DataIndex", "DataIndexView"],
    remote: Optional[str] = None,
):
Severity: Minor
Found in dvc/repo/worktree.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 _clone_default_branch has a Cognitive Complexity of 24 (exceeds 5 allowed). Consider refactoring.
Open

def _clone_default_branch(url, rev):  # noqa: PLR0912
    """Get or create a clean clone of the url.

    The cloned is reactualized with git pull unless rev is a known sha.
    """
Severity: Minor
Found in dvc/repo/open_repo.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

File utils.py has 308 lines of code (exceeds 250 allowed). Consider refactoring.
Open

import os
import random
import sys
from collections import defaultdict
from collections.abc import Generator, Iterable, Mapping
Severity: Minor
Found in dvc/repo/experiments/utils.py - About 3 hrs to fix

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

    import os
    import re
    from collections.abc import Iterable
    from typing import TYPE_CHECKING, Optional
    
    
    Severity: Minor
    Found in dvc/repo/experiments/__init__.py - About 3 hrs to fix

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

      import argparse
      import logging
      from collections.abc import Iterable
      from contextlib import contextmanager
      from itertools import chain, filterfalse
      Severity: Minor
      Found in dvc/commands/stage.py - About 3 hrs to fix

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

            def match_queue_entry_by_name(
                self,
                exp_names: Collection[str],
                *entries: Iterable[Union[QueueEntry, QueueDoneResult]],
            ) -> dict[str, Optional[QueueEntry]]:
        Severity: Minor
        Found in dvc/repo/experiments/queue/base.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 _show_status has a Cognitive Complexity of 23 (exceeds 5 allowed). Consider refactoring.
        Open

            def _show_status(cls, status: "DataStatus") -> int:  # noqa: C901
                git_info = status.pop("git")  # type: ignore[misc]
                result = dict(cls._process_status(status))
                if not result:
                    no_changes = "No changes"
        Severity: Minor
        Found in dvc/commands/data.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

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

        from collections.abc import Iterable, Iterator, Sequence
        from contextlib import contextmanager, nullcontext
        from typing import TYPE_CHECKING, Any, Callable, Optional, TextIO, Union
        
        import colorama
        Severity: Minor
        Found in dvc/ui/__init__.py - About 3 hrs to fix

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

                      self.repo.imp_url(
                          self.args.url,
                          out=self.args.out,
                          no_exec=self.args.no_exec,
                          no_download=self.args.no_download,
          Severity: Major
          Found in dvc/commands/imp_url.py and 1 other location - About 3 hrs to fix
          dvc/commands/imp.py on lines 15..26

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

          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

                      self.repo.imp(
                          self.args.url,
                          self.args.path,
                          out=self.args.out,
                          rev=self.args.rev,
          Severity: Major
          Found in dvc/commands/imp.py and 1 other location - About 3 hrs to fix
          dvc/commands/imp_url.py on lines 13..23

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

          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

          Severity: Major
          Found in dvc/testing/benchmarks/cli/commands/test_get.py and 1 other location - About 3 hrs to fix
          dvc/testing/benchmarks/cli/commands/test_import.py on lines 0..9

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

          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 run has a Cognitive Complexity of 22 (exceeds 5 allowed). Consider refactoring.
          Open

              def run(self) -> int:  # noqa: C901, PLR0911, PLR0912
                  from pathlib import Path
          
                  from dvc.render.match import match_defs_renderers
                  from dvc_render import render_html
          Severity: Minor
          Found in dvc/commands/plots.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

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

          Severity: Major
          Found in dvc/testing/benchmarks/cli/commands/test_import.py and 1 other location - About 3 hrs to fix
          dvc/testing/benchmarks/cli/commands/test_get.py on lines 0..9

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

          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

          File collect.py has 294 lines of code (exceeds 250 allowed). Consider refactoring.
          Open

          import itertools
          import os
          from collections.abc import Collection, Iterable, Iterator
          from dataclasses import fields
          from datetime import datetime
          Severity: Minor
          Found in dvc/repo/experiments/collect.py - About 3 hrs to fix

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

            class BaseStashQueue(ABC):
                """Naive Git-stash based experiment queue.
            
                Maps queued experiments to (Git) stash reflog entries.
                """
            Severity: Minor
            Found in dvc/repo/experiments/queue/base.py - About 3 hrs to fix

              File artifacts.py has 291 lines of code (exceeds 250 allowed). Consider refactoring.
              Open

              import os
              import posixpath
              from pathlib import Path
              from typing import TYPE_CHECKING, Any, Optional, Union
              
              
              Severity: Minor
              Found in dvc/repo/artifacts.py - About 3 hrs to fix

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

                def _data_cells(
                    exp: "ExpState",
                    *,
                    metrics_headers: Iterable[str],
                    params_headers: Iterable[str],
                Severity: Minor
                Found in dvc/repo/experiments/show.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 _sort_column has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring.
                Open

                def _sort_column(  # noqa: C901
                    sort_by: str,
                    metric_names: Mapping[str, Iterable[str]],
                    param_names: Mapping[str, Iterable[str]],
                ) -> tuple[str, str, str]:
                Severity: Minor
                Found in dvc/repo/experiments/show.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 run has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring.
                Open

                    def run(self):  # noqa: C901, PLR0912
                        from dvc.repo.gc import _validate_args
                
                        _validate_args(
                            all_branches=self.args.all_branches,
                Severity: Minor
                Found in dvc/commands/gc.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

                File show.py has 286 lines of code (exceeds 250 allowed). Consider refactoring.
                Open

                import argparse
                import re
                from collections.abc import Iterable
                from datetime import date, datetime
                from typing import TYPE_CHECKING
                Severity: Minor
                Found in dvc/commands/experiments/show.py - About 2 hrs to fix
                  Severity
                  Category
                  Status
                  Source
                  Language