avocado-framework/avocado

View on GitHub
avocado/plugins/vmimage.py

Summary

Maintainability
C
1 day
Test Coverage
F
47%

Function list_downloaded_images has a Cognitive Complexity of 60 (exceeds 5 allowed). Consider refactoring.
Open

def list_downloaded_images():
    """
    List the available Image inside avocado cache
    :return: list with image's parameters
    :rtype: list of dicts
Severity: Minor
Found in avocado/plugins/vmimage.py - About 1 day 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

                    with open(
                        os.path.join(root, metadata_file), "r", encoding="utf-8"
                    ) as data:
                        metadata = json.loads(data.read())
                    if isinstance(metadata, dict):
Severity: Major
Found in avocado/plugins/vmimage.py - About 45 mins to fix

    Avoid deeply nested control flow statements.
    Open

                        if isinstance(metadata, dict):
                            if metadata.get("type", None) == "vmimage":
                                provider = None
                                for p in vmimage.IMAGE_PROVIDERS:
                                    if p.name == metadata["name"]:
    Severity: Major
    Found in avocado/plugins/vmimage.py - About 45 mins to fix

      There are no issues that match your filters.

      Category
      Status