avocado/utils/vmimage.py
Audit url open for permitted schemes. Allowing use of file:/ or custom schemes is often unexpected. Open
Open
data = urlopen(url).read()
- Exclude checks
File vmimage.py
has 577 lines of code (exceeds 250 allowed). Consider refactoring. Open
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.
#
Function __init__
has 9 arguments (exceeds 4 allowed). Consider refactoring. Open
Open
def __init__(
Function from_parameters
has 9 arguments (exceeds 4 allowed). Consider refactoring. Open
Open
def from_parameters(
Function get_versions
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
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)
- Read upRead up
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
Open
def get(
Function handle_starttag
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
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]):
- Read upRead up
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"