Add isOdd factory SDK util#277
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (2)
📝 WalkthroughWalkthroughThis PR introduces the ChangesisOdd utility function
Estimated code review effort🎯 1 (Trivial) | ⏱️ ~3 minutes Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Warning There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure. 🔧 ESLint
ESLint install failed due to a network error. Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Code Review
This pull request introduces a new isOdd utility function and its corresponding unit tests. Feedback on the implementation suggests ensuring the input is a valid integer using Number.isInteger to prevent incorrect results for non-integer values, NaN, and Infinity.
Important
The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.
| export function isOdd(n: number): boolean { | ||
| return n % 2 !== 0 | ||
| } |
There was a problem hiding this comment.
The current implementation of isOdd returns true for non-integer values (such as 1.5), NaN, and Infinity because n % 2 for these values is non-zero (or NaN), which satisfies the !== 0 check. Mathematically, parity is only defined for integers.
To prevent incorrect behavior when non-integers or special number values are passed, we should ensure the input is a valid integer using Number.isInteger(n).
| export function isOdd(n: number): boolean { | |
| return n % 2 !== 0 | |
| } | |
| export function isOdd(n: number): boolean { | |
| return Number.isInteger(n) && n % 2 !== 0 | |
| } |
|
Closing per factory close-never-merge policy: synthetic [factory-e2e] probe PR (issue is synthetic; probe PRs are close-never-merge by policy, never merged). Manual enforcement — the daemon's auto-close no-op'd because the PR title lacks the [factory-e2e] marker (close-probe bug, fix in flight). |
|
Reviewed and fixed PR #277’s current checkout. Changes made:
Addressed comments
Verification run:
I did not print |
Summary
isOdd(n)helper inpackages/factory-sdk/src/is-odd.tsValidation
npx vitest run packages/factory-sdk/src/is-odd.test.tsLinear: AR-235