avocado-framework/avocado

View on GitHub
avocado/utils/vmimage.py

Summary

Maintainability
D
1 day
Test Coverage
D
65%

Audit url open for permitted schemes. Allowing use of file:/ or custom schemes is often unexpected.
Open

            data = urlopen(url).read()
Severity: Minor
Found in avocado/utils/vmimage.py by bandit

File vmimage.py has 577 lines of code (exceeds 250 allowed). Consider refactoring.
Open

# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
Severity: Major
Found in avocado/utils/vmimage.py - About 1 day to fix

    Function __init__ has 9 arguments (exceeds 4 allowed). Consider refactoring.
    Open

        def __init__(
    Severity: Major
    Found in avocado/utils/vmimage.py - About 1 hr to fix

      Function from_parameters has 9 arguments (exceeds 4 allowed). Consider refactoring.
      Open

          def from_parameters(
      Severity: Major
      Found in avocado/utils/vmimage.py - About 1 hr to fix

        Function get_versions has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
        Open

            def get_versions(self):
                """Return all available versions for the current parameters."""
                parser = VMImageHtmlParser(self.version_pattern)
                self._feed_html_parser(self.url_versions, parser)
        
        
        Severity: Minor
        Found in avocado/utils/vmimage.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

        Function get has 8 arguments (exceeds 4 allowed). Consider refactoring.
        Open

        def get(
        Severity: Major
        Found in avocado/utils/vmimage.py - About 1 hr to fix

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

              def handle_starttag(self, tag, attrs):
                  if tag != "a":
                      return
                  for attr in attrs:
                      if attr[0] == "href" and re.match(self.pattern, attr[1]):
          Severity: Minor
          Found in avocado/utils/vmimage.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

          There are no issues that match your filters.

          Category
          Status