Skip to content

Deferred findings: behaviour fixes, API renames, structural cleanups - #16

Merged
diegourban merged 6 commits into
masterfrom
deferred-findings
Nov 6, 2026
Merged

diegourban merged 6 commits into
masterfrom
deferred-findings

Conversation

@diegourban

Copy link
Copy Markdown
Owner

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

Commit Rows What
927faa0 B5, B10, B20, B25 LinkedList.toString → [a,b] (no trailing comma); Vector.toString shows only the stored elements; Statistics.median sorts a copy; Geometry uses Math.PI instead of 3.14. Each has a test that failed first.
c7449a9 N12, N13, N15–N17, N19, N26, N28 API renames: toReversedDigits, digitCount, isRightTriangle, classifyTriangle, SCALENE, getDisplayName, Set → WordSet, fibonacciBinetApproximate. Callers updated.
45e685c L2, L5, O4, O5, O6, O12, O14 Geometry.sortedSides helper; WordSet looks up a bucket once and stores buckets in an ArrayList; isPositionValid → isInsertablePosition; Arrays.copyOf growth; reuse of next; braces and early returns.
ae95c79 B29, L1, O13 Reader.readLine grows its buffer, so lines over 10,000 bytes work (tested with 20,000); skipWhitespace() replaces 4 copies of the same loop; no chained assignments.
749be58 L3, B27 Public ArrayUtils.swap replaces the boxed-Integer swaps in Insertion and Selection sort and QuickSort's private copy; BinarySearch midpoint is from + (to - from) / 2, with the recursion unchanged.
18ce95e README layout line.

Visible changes for callers

  • The renamed APIs above.
  • toString formats of LinkedList and Vector.
  • Geometry circle and cylinder results now use the precise π.
  • median no longer reorders its input.

Test plan

  • ./mvnw clean verify: 616 tests; doclint, Spotless, PMD (it caught one missing final along the way) and coverage floors all pass
  • CI, Codacy, Codecov green

🤖 Generated with Claude Code

diegourban and others added 6 commits November 6, 2026 17:29
…, 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>
@codacy-production

Copy link
Copy Markdown

Up to standards ✅

🟢 Issues 0 issues

Results:
0 new issues

View in Codacy

🟢 Metrics 14 complexity · 2 duplication

Metric Results
Complexity 14
Duplication 2

View in Codacy

AI Reviewer: first review requested successfully. AI can make mistakes. Always validate suggestions.

Run reviewer

TIP This summary will be updated as you push new changes.

@codecov-commenter

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 99.82%. Comparing base (6de0c8f) to head (18ce95e).

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.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@codacy-production codacy-production Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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();

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 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.

See Clone in Codacy

TIP React 👍 if this review is right, or reply with what's wrong and how it could be better to help improve the reviewer.

@diegourban
diegourban merged commit 73540ba into master Nov 6, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants