Repository navigation
Deferred findings: behaviour fixes, API renames, structural cleanups - #16
Conversation
…, B20, B25)
- B5: LinkedList.toString separates names with commas ("[a,b]") instead
of ending each with one ("[a,b,]")
- B10: Vector.toString shows only the stored elements instead of the
whole backing array with 99 nulls
- B20: Statistics.median sorts a copy, leaving the caller's array as it
was
- B25: Geometry uses Math.PI instead of 3.14 for circles and cylinders
Each change has a test that failed before it.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- Numbers.toArray -> toReversedDigits, Numbers.length -> digitCount - Geometry.isRectangleTriangle -> isRightTriangle, checkTriangleType -> classifyTriangle - TriangleType.ESCALENE -> SCALENE, getName() -> getDisplayName() - datastructure.set.Set -> WordSet (no longer shadows java.util.Set); its table/list -> buckets/bucket - Sequences.fibonacciSimpleBinetFormula -> fibonacciBinetApproximate; powInvrt -> negativePhiPower Callers (tests only) updated in the same commit. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- L2: Geometry.sortedSides(a, b, c) replaces the block duplicated in classifyTriangle and isRightTriangle - L5/O12: WordSet looks a word's bucket up once (bucketFor) and keeps its buckets in an ArrayList, so get(i) is O(1) - O4: Vector.isPositionValid -> isInsertablePosition; since B6 it accepts size() and no longer duplicates positionOccupied - O5: Vector grows with Arrays.copyOf - O6: LinkedList.add reuses the next node it already looked up - O14: braces and early returns in Numbers.digitCount, NumberTheory.lcm(long[]) and Statistics.mode; same comparisons in the same order Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- B29: readLine grows its buffer (Arrays.copyOf, doubling from 64 bytes) instead of failing with ArrayIndexOutOfBoundsException on lines over 10,000 bytes; new test reads a 20,000-byte line - L1: skipWhitespace() replaces the loop copied into nextInt, nextLong, nextDouble and nextChar. The sign check stays inline: it yields both the sign and the next byte, which would need a holder object - O13: no chained assignment in the constructor (fields default to 0) and no assignment inside the read(...) argument Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- L3: public ArrayUtils.swap(int[], i, j) (documented and tested) is used by InsertionSort and SelectionSort, which swapped through boxed Integer temporaries, by QuickSort instead of its private copy, and by shuffle. The Sorter property tests cover all four sorts - B27: BinarySearch.find computes the midpoint as from + (to - from) / 2; (from + to) / 2 overflows for arrays above 2^30 elements. The recursion is unchanged Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Up to standards ✅🟢 Issues
|
| Metric | Results |
|---|---|
| Complexity | 14 |
| Duplication | 2 |
AI Reviewer: first review requested successfully. AI can make mistakes. Always validate suggestions.
TIP This summary will be updated as you push new changes.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #16 +/- ##
============================================
- Coverage 99.83% 99.82% -0.01%
+ Complexity 296 295 -1
============================================
Files 24 24
Lines 594 574 -20
Branches 102 101 -1
============================================
- Hits 593 573 -20
Partials 1 1 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Pull Request Overview
👀 Worth a closer look
Reader may corrupt parsing for streams that temporarily return zero bytes without reaching EOF; this should be reviewed before merging. The relevant parsing code has no uncovered-complex-file flag, but targeted regression coverage is still needed for the missing sorting and binary-search scenarios.
Test suggestions
- Verify LinkedList string formatting without a trailing comma, including empty and multi-element lists.
- Verify Vector string formatting includes only stored elements, including an empty vector.
- Verify median returns the correct result without modifying the input array.
- Verify circle and cylinder calculations use precise Math.PI.
- Verify renamed number, geometry, triangle, set, and Fibonacci APIs and their expected results.
- Verify Reader reads lines longer than the initial buffer and continues correctly afterward.
- Verify ArrayUtils.swap exchanges distinct positions and safely handles identical positions.
- Verify all sorting implementations still sort correctly after using the shared swap helper.
- Verify WordSet bucket lookup, duplicate suppression, removal, and empty-word validation.
- Verify BinarySearch behavior for large index ranges where midpoint addition could overflow.
Prompt proposal for missing tests
Consider implementing these tests if applicable:
1. Verify all sorting implementations still sort correctly after using the shared swap helper.
2. Verify BinarySearch behavior for large index ranges where midpoint addition could overflow.
Low confidence findings
- The public API renames appear intentionally breaking; consider documenting a migration path or providing a deprecation/compatibility strategy for existing callers.
Make this review better
TIP Add a ticket key to the branch or title so the reviewer can check the PR against it. Or tell us which ticket tracker you use here.
TIP Add Codacy review.md instructions or an AGENTS.md so the reviewer knows your conventions.
TIP How was this review? Give us feedback
| while (nextByte <= ' ') { | ||
| nextByte = read(); | ||
| } | ||
| byte nextByte = skipWhitespace(); |
There was a problem hiding this comment.
🟡 MEDIUM RISK
Suggestion: Consider extracting shared token acquisition or digit-parsing logic from the numeric reader methods so future parser fixes remain consistent across numeric types.
TIP React 👍 if this review is right, or reply with what's wrong and how it could be better to help improve the reviewer.
The deferred rows from the clean-code findings list, approved in review. One commit per group; L4 (MergeSort split) and B21 (running mean) were declined.
Commits
927faa0LinkedList.toString→[a,b](no trailing comma);Vector.toStringshows only the stored elements;Statistics.mediansorts a copy;GeometryusesMath.PIinstead of 3.14. Each has a test that failed first.c7449a9toReversedDigits,digitCount,isRightTriangle,classifyTriangle,SCALENE,getDisplayName,Set→WordSet,fibonacciBinetApproximate. Callers updated.45e685cGeometry.sortedSideshelper;WordSetlooks up a bucket once and stores buckets in anArrayList;isPositionValid→isInsertablePosition;Arrays.copyOfgrowth; reuse ofnext; braces and early returns.ae95c79Reader.readLinegrows its buffer, so lines over 10,000 bytes work (tested with 20,000);skipWhitespace()replaces 4 copies of the same loop; no chained assignments.749be58ArrayUtils.swapreplaces the boxed-Integerswaps in Insertion and Selection sort and QuickSort's private copy;BinarySearchmidpoint isfrom + (to - from) / 2, with the recursion unchanged.18ce95eVisible changes for callers
toStringformats ofLinkedListandVector.Geometrycircle and cylinder results now use the precise π.medianno longer reorders its input.Test plan
./mvnw clean verify: 616 tests; doclint, Spotless, PMD (it caught one missingfinalalong the way) and coverage floors all pass🤖 Generated with Claude Code