iterative/dvc

View on GitHub
dvc/commands/plots.py

Summary

Maintainability
C
1 day
Test Coverage

File plots.py has 337 lines of code (exceeds 250 allowed). Consider refactoring.
Open

import argparse
import os
from typing import TYPE_CHECKING, Optional

from funcy import compact, first, get_in
Severity: Minor
Found in dvc/commands/plots.py - About 4 hrs to fix

    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

    Function add_parser has 29 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    def add_parser(subparsers, parent_parser):
        PLOTS_HELP = "Commands to visualize and compare plot data."
    
        plots_parser = subparsers.add_parser(
            "plots",
    Severity: Minor
    Found in dvc/commands/plots.py - About 1 hr to fix

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

          def run(self):
              from dvc.exceptions import InvalidArgumentError
              from dvc_render.vega_templates import TEMPLATES
      
              try:
      Severity: Minor
      Found in dvc/commands/plots.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 0
      Severity: Major
      Found in dvc/commands/plots.py - About 30 mins to fix

        Avoid too many return statements within this function.
        Open

                    return 1
        Severity: Major
        Found in dvc/commands/plots.py - About 30 mins to fix

          Avoid too many return statements within this function.
          Open

                              return ui.open_browser(output_file)
          Severity: Major
          Found in dvc/commands/plots.py - About 30 mins to fix

            Avoid too many return statements within this function.
            Open

                            return 0
            Severity: Major
            Found in dvc/commands/plots.py - About 30 mins to fix

              There are no issues that match your filters.

              Category
              Status