Skip to content

Commit 9dcfc93

Browse files
kiblikmtesauro
andauthored
Ruff: Add and autofix PLR1714 (#13004)
Co-authored-by: Matt Tesauro <mtesauro@gmail.com>
1 parent 719fae3 commit 9dcfc93

33 files changed

Lines changed: 36 additions & 57 deletions

File tree

dojo/api_v2/permissions.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ def check_object_permission(
4848
):
4949
if request.method == "GET":
5050
return user_has_permission(request.user, obj, get_permission)
51-
if request.method == "PUT" or request.method == "PATCH":
51+
if request.method in {"PUT", "PATCH"}:
5252
return user_has_permission(request.user, obj, put_permission)
5353
if request.method == "DELETE":
5454
return user_has_permission(request.user, obj, delete_permission)

dojo/cred/views.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -616,7 +616,7 @@ def delete_cred_controller(request, destination_url, elem_id, ttid):
616616
cred_id=cred.cred_id).exclude(finding__isnull=True)
617617
message = "Credential is associated with finding(s). Remove the finding(s) before this credential can be deleted."
618618
delete_cred = True
619-
elif destination_url == "view_test" or destination_url == "view_finding":
619+
elif destination_url in {"view_test", "view_finding"}:
620620
delete_cred = True
621621

622622
# Allow deletion if no credentials are associated

dojo/engagement/views.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -280,7 +280,7 @@ def edit_engagement(request, eid):
280280
new_status = form.cleaned_data.get("status")
281281
engagement.product = form.cleaned_data.get("product")
282282
engagement = form.save(commit=False)
283-
if (new_status == "Cancelled" or new_status == "Completed"):
283+
if (new_status in {"Cancelled", "Completed"}):
284284
engagement.active = False
285285
else:
286286
engagement.active = True

dojo/finding/views.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3327,10 +3327,7 @@ def calculate_possible_related_actions_for_similar_finding(
33273327
},
33283328
)
33293329

3330-
if (
3331-
similar_finding.duplicate_finding == finding
3332-
or similar_finding.duplicate_finding == finding.duplicate_finding
3333-
):
3330+
if similar_finding.duplicate_finding in {finding, finding.duplicate_finding}:
33343331
# duplicate inside the same cluster
33353332
actions.append(
33363333
{

dojo/management/commands/migrate_surveys.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ def handle(self, *args, **options):
5454
copy_string = "INSERT INTO `" + new_table_name + "` SELECT * FROM `" + table + "`;"
5555
cursor.execute(str(copy_string))
5656
# Update polymorphic id on some tables
57-
if new_table_name == "dojo_question" or new_table_name == "dojo_answer":
57+
if new_table_name in {"dojo_question", "dojo_answer"}:
5858
update_string = "UPDATE `" + new_table_name + "` SET polymorphic_ctype_id = " + str(ctype_id) + ";"
5959
cursor.execute(str(update_string))
6060
# Drop the ddse table

dojo/product/views.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -640,7 +640,7 @@ def view_product_metrics(request, pid):
640640
open_close_weekly[unix_timestamp] = {"closed": 0, "open": 1, "accepted": 0}
641641
open_close_weekly[unix_timestamp]["week"] = html_date
642642

643-
if view == "Finding" or view == "Endpoint":
643+
if view in {"Finding", "Endpoint"}:
644644
severity = finding.get("severity")
645645

646646
finding_age = calculate_finding_age(finding)

dojo/templatetags/display_tags.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -706,7 +706,7 @@ def get_severity_count(elem_id, table_type):
706706

707707
if table_type == "test":
708708
display_counts.append("Total: " + str(total) + " Findings")
709-
elif table_type == "engagement" or table_type == "product":
709+
elif table_type in {"engagement", "product"}:
710710
display_counts.append("Total: " + str(total) + " Active Findings")
711711

712712
return ", ".join([str(item) for item in display_counts])

dojo/tools/anchore_engine/parser.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ def get_findings_without_metadata(self, data, test):
135135
)
136136

137137
sev = item["severity"]
138-
if sev == "Negligible" or sev == "Unknown":
138+
if sev in {"Negligible", "Unknown"}:
139139
sev = "Info"
140140

141141
mitigation = (

dojo/tools/anchore_grype/parser.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -206,7 +206,7 @@ def get_findings(self, file, test):
206206
return list(dupes.values())
207207

208208
def _convert_severity(self, val):
209-
if val == "Unknown" or val == "Negligible":
209+
if val in {"Unknown", "Negligible"}:
210210
return "Info"
211211
return val.title()
212212

dojo/tools/anchorectl_vulns/parser.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ def get_findings(self, filename, test):
5151
)
5252

5353
sev = item["severity"]
54-
if sev == "Negligible" or sev == "Unknown":
54+
if sev in {"Negligible", "Unknown"}:
5555
sev = "Info"
5656

5757
if item["fix"] != "None":

0 commit comments

Comments
 (0)