File hawk_test_driver.py
has 586 lines of code (exceeds 250 allowed). Consider refactoring. Open
#!/usr/bin/python3
# Copyright (C) 2019 SUSE LLC
"""Define Selenium driver related functions and classes to test the HAWK GUI"""
import ipaddress
HawkTestDriver
has 27 functions (exceeds 20 allowed). Consider refactoring. Open
class HawkTestDriver:
def __init__(self, addr='localhost', port='7630', browser='firefox', headless=False, version='15-SP5'):
self.addr = addr
self.port = port
self.driver = None
Function test_check_cluster_configuration
has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring. Open
def test_check_cluster_configuration(self, ssh):
print(f"TEST: test_check_cluster_configuration: Check crm options")
self.click_if_major_version("15", 'configuration')
self.check_and_click_by_xpath("Click on Cluster Configuration", [Xpath.HREF_CRM_CONFIG_EDIT])
- 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 test_add_primitive
has 33 lines of code (exceeds 25 allowed). Consider refactoring. Open
def test_add_primitive(self, primitive):
print(f"TEST: test_add_primitive: Add Resources: Primitive {primitive}")
self.click_if_major_version("15", 'configuration')
self.click_on('Resource')
self.check_and_click_by_xpath("Click on Add Resource", [Xpath.RESOURCES_TYPES])
Function test_add_virtual_ip
has 27 lines of code (exceeds 25 allowed). Consider refactoring. Open
def test_add_virtual_ip(self, virtual_ip):
print("TEST: test_add_virtual_ip: Add virtual IP from the Wizard")
self.click_if_major_version("15", 'configuration')
broadcast = str(ipaddress.IPv4Network(virtual_ip, False).broadcast_address)
virtual_ip, netmask = virtual_ip.split('/')
Function __init__
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
def __init__(self, addr='localhost', port='7630', browser='firefox', headless=False, version='15-SP5'):
Function test_add_new_cluster
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def test_add_new_cluster(self, cluster):
print("TEST: test_add_new_cluster")
self.click_on('Dashboard')
self.check_and_click_by_xpath("Click on Dashboard", [Xpath.HREF_DASHBOARD])
elem = self.find_element(By.CLASS_NAME, "btn-default")
- 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 test_remove_cluster
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def test_remove_cluster(self, cluster):
print("TEST: test_remove_cluster")
self.click_on('Dashboard')
self.check_and_click_by_xpath("Click on Dashboard", [Xpath.HREF_DASHBOARD])
elem = self.find_element(By.PARTIAL_LINK_TEXT, cluster)
- 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
Avoid too many return
statements within this function. Open
return True
Avoid too many return
statements within this function. Open
return False
Avoid too many return
statements within this function. Open
return False
Avoid too many return
statements within this function. Open
return False
Avoid too many return
statements within this function. Open
return self.test_status
Avoid too many return
statements within this function. Open
return False
Avoid too many return
statements within this function. Open
return False