Skip to content

Commit

Permalink
Fix SonarCloud security hotspots (#1718)
Browse files Browse the repository at this point in the history
  • Loading branch information
arkid15r committed Mar 6, 2024
1 parent b120e5e commit f770387
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 12 deletions.
19 changes: 9 additions & 10 deletions scripts/generate_release_notes.py
Original file line number Diff line number Diff line change
Expand Up @@ -114,22 +114,20 @@ def is_ready(self):
@property
def sorted_pull_requests(self):
def custom_order(pr):
pr = re.findall(r"^(.*) \(#\d+ .*\)$", pr)[0]

if re.findall(r"^(Introduce|Refactor)", pr) or re.findall(r"Add .* support", pr):
if re.findall(r"^(Introduce|Refactor)", pr[0]) or re.findall(r"Add .* support", pr[0]):
weight = 10
elif re.findall(r"^Add .* holidays$", pr):
elif re.findall(r"^Add .* holidays$", pr[0]):
weight = 20
elif re.findall(r"(^Localize|localization$)", pr):
elif re.findall(r"(^Localize)|(localization$)", pr[0]):
weight = 30
elif re.findall(r"^Fix", pr):
elif re.findall(r"^Fix", pr[0]):
weight = 40
elif re.findall(r"^(Change|Improve|Optimize|Update|Upgrade)", pr):
elif re.findall(r"^(Change|Improve|Optimize|Update|Upgrade)", pr[0]):
weight = 50
else:
weight = 100

return (weight, pr)
return weight, pr

return sorted(self.pull_requests.values(), key=custom_order)

Expand Down Expand Up @@ -158,7 +156,8 @@ def add_pull_request(self, pull_request):
contributors.remove(author)
contributors = (f"@{c}" for c in [author] + sorted(contributors, key=str.lower))
self.pull_requests[pull_request.number] = (
f"{pull_request.title} (#{pull_request.number} by " f"{', '.join(contributors)})"
pull_request.title,
f"#{pull_request.number} by {', '.join(contributors)}",
)

def generate_release_notes(self):
Expand Down Expand Up @@ -246,7 +245,7 @@ def print_release_notes(self):
year=today.year,
)
)
print("\n".join((f"- {pr}" for pr in self.sorted_pull_requests)))
print("\n".join((f"- {pr[0]} ({pr[1]})" for pr in self.sorted_pull_requests)))

else:
print(f"No changes since {self.latest_tag_name} release.")
Expand Down
4 changes: 2 additions & 2 deletions tests/test_docs.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,9 @@ def test_supported_countries_table(self):
country_subdivisions_aliases = {}
country_supported_languages = {}
country_supported_categories = {}
subdivision_group_re = re.compile(".*: (.*)")
subdivision_group_re = re.compile("\w+: ([\s\w,*()]+)")
subdivision_and_aliases_re = re.compile(r",(?![^()]*\))")
subdivision_aliases_re = re.compile(r"(.*)\s\((.*?)\)")
subdivision_aliases_re = re.compile(r"(.*?)\s\((.*?)\)")

table_content = [
line.strip()
Expand Down

0 comments on commit f770387

Please sign in to comment.