iterative/dvc

View on GitHub
dvc/render/converter/vega.py

Summary

Maintainability
B
6 hrs
Test Coverage

File vega.py has 260 lines of code (exceeds 250 allowed). Consider refactoring.
Open

import os
from collections.abc import Iterable
from typing import Any, Optional, Union

from funcy import first, last
Severity: Minor
Found in dvc/render/converter/vega.py - About 2 hrs to fix

    Function _infer_x_y has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
    Open

        def _infer_x_y(self):
            x = self.properties.get("x", None)
            y = self.properties.get("y", None)
    
            inferred_properties: dict = {}
    Severity: Minor
    Found in dvc/render/converter/vega.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

    Avoid deeply nested control flow statements.
    Open

                        for field in val:
                            yield file, field
    
    
    Severity: Major
    Found in dvc/render/converter/vega.py - About 45 mins to fix

      Avoid too many return statements within this function.
      Open

                  return first(fields)
      Severity: Major
      Found in dvc/render/converter/vega.py - About 30 mins to fix

        Avoid too many return statements within this function.
        Open

                return "y"
        Severity: Major
        Found in dvc/render/converter/vega.py - About 30 mins to fix

          Function _infer_y_from_data has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
          Open

              def _infer_y_from_data(self):
                  if self.plot_id in self.data:
                      for lst in _lists(self.data[self.plot_id]):
                          if all(isinstance(item, dict) for item in lst):
                              datapoint = first(lst)
          Severity: Minor
          Found in dvc/render/converter/vega.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