feat: add string utility helpers - #36
Conversation
SummaryThis PR adds a new
Note: The PR description mentions verifying telemetry events and an organizationUuid fix, but the actual changes are limited to adding these utility helpers. Clarify whether this is the complete scope or if telemetry-related changes are pending. What reviewers should knowWhat to review:
To understand context:
Diagram%%{init: {'flowchart': {'curve': 'catmullRom'}}}%%
flowchart TD
input([Input string s])
input --> truncate
input --> capitalize_words
input --> count_vowels
input --> reverse_words
input --> is_palindrome
truncate["truncate(s, max_length)\nValidates max_length ≥ 0\nReturns s[:max_length]"]
capitalize_words["capitalize_words(s)\nSplits on whitespace\nCapitalizes each word\nRejoins with single space"]
count_vowels["count_vowels(s)\nLowercases s\nCounts chars in 'aeiou'"]
reverse_words["reverse_words(s)\nSplits on whitespace\nReverses word list\nRejoins with single space"]
is_palindrome["is_palindrome(s)\nStrips non-alphanumeric\nLowercases\nCompares string to its reverse"]
truncate --> strOut([str])
capitalize_words --> strOut
count_vowels --> intOut([int])
reverse_words --> strOut
is_palindrome --> boolOut([bool])
|
SonarQube reviewer guide
|
|
|
||
| def truncate(s: str, max_length: int) -> str: | ||
| if max_length < 0: | ||
| raise ValueError("max_length must be non-negative") |
There was a problem hiding this comment.
Missing test coverage: The ValueError path for negative max_length is untested. A unit test passing -1 should assert this raises ValueError. Without it, any future refactor of this guard could silently drop the validation.
- Mark as noise
| def is_palindrome(s: str) -> bool: | ||
| cleaned = ''.join(c.lower() for c in s if c.isalnum()) | ||
| return cleaned == cleaned[::-1] |
There was a problem hiding this comment.
Missing test coverage: The cleaning step (strip non-alphanumeric, lowercase) is non-trivial and has at least two untested edge cases:
- Empty string input (
"") — returnsTrue(vacuously a palindrome); confirm this is intentional. - Mixed-case input with punctuation (e.g.
"A man, a plan, a canal: Panama") — exercises both theisalnum()filter and the.lower()call together.
A unit test covering each of these would catch regressions in the cleaning logic independently of the palindrome check itself.
- Mark as noise



Test PR to verify Gessie telemetry events (organizationUuid fix)