Skip to content
Snippets Groups Projects
Verified Commit 383fec8e authored by Karel van Klink's avatar Karel van Klink :smiley_cat:
Browse files

Resolve some issues in SonarQube

parent d53b9ef8
No related branches found
No related tags found
1 merge request!330Feature/sonarqube improvements
Pipeline #90945 passed
......@@ -54,10 +54,10 @@ def validate_juniper_phy_interface_name(interface_name: str) -> str:
Returns:
The interface name if match was successful, otherwise it will throw a ValueError exception.
"""
pattern = re.compile(r"^(ge|et|xe)-1?[0-9]/[0-9]{1,2}/[0-9]{1,2}$")
pattern = re.compile(r"^(ge|et|xe)-1?\d/\d{1,2}/\d{1,2}$")
if not bool(pattern.match(interface_name)):
error_msg = (
f"Invalid interface name. The interface name should be of format: xe-1/0/0. " f"Got: {interface_name}"
f"Invalid interface name. The interface name should be of format: xe-1/0/0, received: {interface_name}"
)
raise ValueError(error_msg)
return interface_name
......@@ -113,7 +113,7 @@ def bandwidth_string_is_valid(bandwidth_string: str) -> str:
if len(bandwidth_string) < 2: # noqa: PLR2004 not a magic value
raise ValueError(msg)
if bandwidth_string[-1:] not in "K" "M" "G" "T":
if bandwidth_string[-1:] not in set("K" "M" "G" "T"):
raise ValueError(msg)
try:
......
......@@ -11,7 +11,7 @@ def validate_site_name(site_name: str) -> str:
The site name must consist of three uppercase letters, optionally followed by a single digit.
"""
pattern = re.compile(r"^[A-Z]{3}[0-9]?$")
pattern = re.compile(r"^[A-Z]{3}\d?$")
if not pattern.match(site_name):
msg = (
"Enter a valid site name. It must consist of three uppercase letters (A-Z), followed by an optional single "
......
......@@ -154,7 +154,7 @@ def initialize_subscription(
subscription.edge_port.ga_id = ga_id
subscription.edge_port.mac_address = mac_address
partner_name = get_partner_by_id(partner).name
subscription.description = f"Edge Port {name} on {router.router_fqdn}, " f"{partner_name}, {ga_id or ""}"
subscription.description = f"Edge Port {name} on {router.router_fqdn}, {partner_name}, {ga_id or ""}"
subscription.edge_port.edge_port_description = description
for member in ae_members:
subscription.edge_port.edge_port_ae_members.append(
......
......@@ -445,7 +445,7 @@ def update_remaining_side_bfd_dry(
"verb": "update",
"config_object": "bfd_update",
"dry_run": True,
"commit_comment": f"GSO_PROCESS_ID: {process_id} - TT_NUMBER: {tt_number} " f"- Update BFD config.",
"commit_comment": f"GSO_PROCESS_ID: {process_id} - TT_NUMBER: {tt_number} - Update BFD config.",
}
return {
......@@ -473,7 +473,7 @@ def update_remaining_side_bfd_real(
"verb": "update",
"config_object": "bfd_update",
"dry_run": False,
"commit_comment": f"GSO_PROCESS_ID: {process_id} - TT_NUMBER: {tt_number} " f"- Update BFD config.",
"commit_comment": f"GSO_PROCESS_ID: {process_id} - TT_NUMBER: {tt_number} - Update BFD config.",
}
return {
......
......@@ -107,7 +107,7 @@ def layer_2_circuit_subscription_factory(faker, geant_partner, edge_port_subscri
subscription.layer_2_circuit.bandwidth = None
subscription.layer_2_circuit.policer_burst_rate = None
subscription.description = description or (
f"{subscription.product.name} - " f"{subscription.layer_2_circuit.virtual_circuit_id}"
f"{subscription.product.name} - {subscription.layer_2_circuit.virtual_circuit_id}"
)
subscription = SubscriptionModel.from_other_lifecycle(subscription, SubscriptionLifecycle.ACTIVE)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment