feat: add data utility functions - #31
Conversation
SummaryThis PR adds a new
The PR is described as a test to validate that org review guidelines (from ~/CLAUDE.md) are properly injected and picked up by the review agent. What reviewers should knowWhat to review:
Things to note:
|
SonarQube reviewer guide
|
There was a problem hiding this comment.
There are two real crash bugs in normalize() that need to be fixed before merge.
SonarQube Cloud status: Coverage on new code is 0% against an 80% threshold — see the reviewer guide above for details. The coverage gap is meaningful here: the uncovered edge cases in normalize() are exactly the paths that contain bugs.
| def normalize(values): | ||
| mn = min(values) | ||
| mx = max(values) | ||
| return [(v - mn) / (mx - mn) for v in values] |
There was a problem hiding this comment.
Missing test coverage: normalize() has two unguarded crash paths that no test currently exercises:
- Empty list —
min([])raisesValueError. There is no guard before callingmin/max. - All-identical values — when every element is the same,
mx - mn == 0, causingZeroDivisionErroron the return line.
Both will blow up in production on valid-looking inputs. The uniform-values case is especially sneaky because a caller has no obvious reason to expect a crash.
A minimal fix for the zero-division case:
| def normalize(values): | |
| mn = min(values) | |
| mx = max(values) | |
| return [(v - mn) / (mx - mn) for v in values] | |
| def normalize(values): | |
| mn = min(values) | |
| mx = max(values) | |
| if mx == mn: | |
| return [0.0] * len(values) | |
| return [(v - mn) / (mx - mn) for v in values] |
- Mark as noise
| return result | ||
|
|
||
|
|
||
| def chunk(lst, size): |
There was a problem hiding this comment.
Missing test coverage: chunk(lst, 0) raises ValueError: range() arg 3 must not be zero with no helpful message. Since size comes from the caller, a zero or negative value is a plausible mistake. Add a guard and a clear error:
if size <= 0:
raise ValueError(f"size must be a positive integer, got {size}")- Mark as noise



Test PR to validate that org review guidelines are injected via ~/CLAUDE.md and picked up by the review agent.