Skip to content

Commit 41b3bfb

Browse files
authored
Ruff: Add and fix PLR6104 (#11716)
1 parent 1ef38da commit 41b3bfb

File tree

34 files changed

+58
-78
lines changed

34 files changed

+58
-78
lines changed

dojo/benchmark/views.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -118,9 +118,7 @@ def return_score(queryset):
118118
for item in queryset:
119119
if item["pass_fail"]:
120120
asvs_level_1_score = item["pass_fail__count"]
121-
asvs_level_1_benchmark = (
122-
asvs_level_1_benchmark + item["pass_fail__count"]
123-
)
121+
asvs_level_1_benchmark += item["pass_fail__count"]
124122

125123
return asvs_level_1_benchmark, asvs_level_1_score
126124

dojo/filters.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -334,8 +334,7 @@ def __init__(self, *args, **kwargs):
334334
# we defer applying the select2 autocomplete because there can be multiple forms on the same page
335335
# and form.js would then apply select2 multiple times, resulting in duplicated fields
336336
# the initialization now happens in filter_js_snippet.html
337-
self.form.fields[field].widget.tag_options = \
338-
self.form.fields[field].widget.tag_options + tagulous.models.options.TagOptions(autocomplete_settings={"width": "200px", "defer": True})
337+
self.form.fields[field].widget.tag_options += tagulous.models.options.TagOptions(autocomplete_settings={"width": "200px", "defer": True})
339338
tagged_model, exclude = get_tags_model_from_field_name(field)
340339
if tagged_model: # only if not the normal tags field
341340
self.form.fields[field].label = get_tags_label_from_model(tagged_model)
@@ -1592,7 +1591,7 @@ def __init__(self, *args, **kwargs):
15921591
super().__init__(*args, **kwargs)
15931592

15941593
def filter_percentage(self, queryset, name, value):
1595-
value = value / decimal.Decimal("100.0")
1594+
value /= decimal.Decimal("100.0")
15961595
# Provide some wiggle room for filtering since the UI rounds to two places (and because floats):
15971596
# a user may enter 0.15, but we'll return everything in [0.0015, 0.0016).
15981597
# To do this, add to our value 1^(whatever the exponent for our least significant digit place is), but ensure

dojo/finding/views.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1379,9 +1379,9 @@ def defect_finding_review(request, fid):
13791379
# Add the closing note
13801380
if push_to_jira and not finding_in_group:
13811381
if defect_choice == "Close Finding":
1382-
new_note.entry = new_note.entry + "\nJira issue set to resolved."
1382+
new_note.entry += "\nJira issue set to resolved."
13831383
else:
1384-
new_note.entry = new_note.entry + "\nJira issue re-opened."
1384+
new_note.entry += "\nJira issue re-opened."
13851385
jira_helper.add_comment(finding, new_note, force_push=True)
13861386
# Save the finding
13871387
finding.save(push_to_jira=(push_to_jira and not finding_in_group))

dojo/metrics/utils.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -433,7 +433,7 @@ def get_charting_data(
433433
if period == MetricsPeriod.WEEK:
434434
# For weeks, start at the first day of the specified week
435435
start_date = datetime(start_date.year, start_date.month, start_date.day, tzinfo=tz)
436-
start_date = start_date + timedelta(days=-start_date.weekday())
436+
start_date += timedelta(days=-start_date.weekday())
437437
else:
438438
# For months, start on the first day of the month
439439
start_date = datetime(start_date.year, start_date.month, 1, tzinfo=tz)

dojo/models.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -857,11 +857,11 @@ def calc_health(self):
857857
health = 100
858858
if c_findings.count() > 0:
859859
health = 40
860-
health = health - ((c_findings.count() - 1) * 5)
860+
health -= ((c_findings.count() - 1) * 5)
861861
if h_findings.count() > 0:
862862
if health == 100:
863863
health = 60
864-
health = health - ((h_findings.count() - 1) * 2)
864+
health -= ((h_findings.count() - 1) * 2)
865865
if health < 5:
866866
return 5
867867
return health
@@ -2835,16 +2835,16 @@ def compute_hash_code(self):
28352835
if hashcodeField == "endpoints":
28362836
# For endpoints, need to compute the field
28372837
myEndpoints = self.get_endpoints()
2838-
fields_to_hash = fields_to_hash + myEndpoints
2838+
fields_to_hash += myEndpoints
28392839
deduplicationLogger.debug(hashcodeField + " : " + myEndpoints)
28402840
elif hashcodeField == "vulnerability_ids":
28412841
# For vulnerability_ids, need to compute the field
28422842
my_vulnerability_ids = self.get_vulnerability_ids()
2843-
fields_to_hash = fields_to_hash + my_vulnerability_ids
2843+
fields_to_hash += my_vulnerability_ids
28442844
deduplicationLogger.debug(hashcodeField + " : " + my_vulnerability_ids)
28452845
else:
28462846
# Generically use the finding attribute having the same name, converts to str in case it's integer
2847-
fields_to_hash = fields_to_hash + str(getattr(self, hashcodeField))
2847+
fields_to_hash += str(getattr(self, hashcodeField))
28482848
deduplicationLogger.debug(hashcodeField + " : " + str(getattr(self, hashcodeField)))
28492849
deduplicationLogger.debug("compute_hash_code - fields_to_hash = " + fields_to_hash)
28502850
return self.hash_fields(fields_to_hash)

dojo/settings/settings.dist.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -884,7 +884,7 @@ def generate_url(scheme, double_slashes, user, password, host, port, path, param
884884
# https://warehouse.python.org/project/whitenoise/
885885
"whitenoise.middleware.WhiteNoiseMiddleware",
886886
]
887-
MIDDLEWARE = MIDDLEWARE + WHITE_NOISE
887+
MIDDLEWARE += WHITE_NOISE
888888

889889
EMAIL_CONFIG = env.email_url(
890890
"DD_EMAIL_URL", default="smtp://user@:password@localhost:25")

dojo/survey/views.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -789,7 +789,7 @@ def answer_empty_survey(request, esid):
789789
survey.responder = request.user if not request.user.is_anonymous else None
790790
survey.answered_on = date.today()
791791
survey.save()
792-
general_survey.num_responses = general_survey.num_responses + 1
792+
general_survey.num_responses += 1
793793
general_survey.save()
794794
if request.user.is_anonymous:
795795
message = "Your responses have been recorded."

dojo/templatetags/announcement_banner_tags.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
@register.filter
1010
def bleach_announcement_message(message):
1111
allowed_attributes = bleach.ALLOWED_ATTRIBUTES
12-
allowed_attributes["a"] = allowed_attributes["a"] + ["style", "target"]
12+
allowed_attributes["a"] += ["style", "target"]
1313
return mark_safe(bleach.clean(
1414
message,
1515
attributes=allowed_attributes,

dojo/templatetags/get_banner.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ def get_banner_conf(attribute):
1717
if attribute == "banner_message":
1818
# only admin can edit login banner, so we allow html, but still bleach it
1919
allowed_attributes = bleach.ALLOWED_ATTRIBUTES
20-
allowed_attributes["a"] = allowed_attributes["a"] + ["style", "target"]
20+
allowed_attributes["a"] += ["style", "target"]
2121
return mark_safe(bleach.clean(
2222
value,
2323
attributes=allowed_attributes,

dojo/tools/api_bugcrowd/api_client.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ def test_product_connection(self, api_scan_configuration):
136136
api_scan_configuration.service_key_2,
137137
)
138138
for page in submission_gen:
139-
submissions = submissions + page
139+
submissions += page
140140
submission_number = len(submissions)
141141
return (
142142
f'You have access to "{submission_number}" submissions (no duplicates)'

0 commit comments

Comments
 (0)