iterative/dvc

View on GitHub
dvc/utils/strictyaml.py

Summary

Maintainability
B
5 hrs
Test Coverage

Function __pretty_exc__ has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
Open

    def __pretty_exc__(self, **kwargs: Any) -> None:  # noqa: C901
        from ruamel.yaml.error import MarkedYAMLError

        exc = self.exc.__cause__

Severity: Minor
Found in dvc/utils/strictyaml.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 _prepare_context has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
Open

    def _prepare_context(self, data: typing.Mapping) -> list[object]:
        lines: list[object] = []
        for index, error in enumerate(self.exc.errors):
            if index and lines[-1]:
                lines.append("")
Severity: Minor
Found in dvc/utils/strictyaml.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

Consider simplifying this complex logical expression.
Open

            if exc.context_mark is not None and (
                exc.problem is None
                or exc.problem_mark is None
                or exc.context_mark.name != exc.problem_mark.name
                or exc.context_mark.line != exc.problem_mark.line
Severity: Major
Found in dvc/utils/strictyaml.py - About 40 mins to fix

    Function load has 5 arguments (exceeds 4 allowed). Consider refactoring.
    Open

    def load(
    Severity: Minor
    Found in dvc/utils/strictyaml.py - About 35 mins to fix

      Function validate has 5 arguments (exceeds 4 allowed). Consider refactoring.
      Open

      def validate(
      Severity: Minor
      Found in dvc/utils/strictyaml.py - About 35 mins to fix

        There are no issues that match your filters.

        Category
        Status