leerho opened a new pull request, #792:
URL: https://github.com/apache/datasketches-java/pull/792
Cleans up most of the open CodeQL alerts. The library-code changes don't
change behavior; one test fix corrects a real test bug.
## Library code
| Alert | Where | Change |
|---|---|---|
| index out of bounds (error) | `Util.convertToLongArray` | Walk each 8-byte
group forward with an explicit exclusive `end`, so the bounds are visible. The
output is identical (`UtilTest.checkConvertToLongArray` still passes). |
| value may be null (2) | `ReservoirItemsUnion` / `ReservoirLongsUnion`
`toByteArray()` | Derive `empty` from `gadgetBytes == null`, so the guard
covers the dereference directly. |
## Tests
- **Real bug:** `UtilTest.checkCeilingMultiple2expK` used `(1 << 36) - 1L`.
That's an int shift, which Java masks to `1 << 4`, so the test only ever
checked n = 15. It now uses `1L << 36`.
- `PositionalSegmentTest`: compute offsets as `(long) i * X.BYTES` (21
integer-multiplication alerts).
- Remove locals that were assigned but never read. Where the call is what's
being tested, the call stays as a statement. Two tests got stronger along the
way: `CpcWrapperTest` now asserts the empty-sketch estimate and bounds it used
to discard, and `ArrayOfDoublesCompactSketchTest` asserts the type its unused
cast was checking.
## Deliberately not changed
These are better dismissed in the code-scanning UI:
- `KllPreambleUtil.toString()` (2 null warnings): it already calls
`Objects.requireNonNull(serDe, ...)` for items sketches. CodeQL can't connect
that guard to the later `else //ITEMS_SKETCH` branch.
- The `println(String s) { //System.out.println(s); }` debug helpers
(unused-parameter alerts): the commented-out body is the intended toggle.
- Locals read only by commented-out debug `println`s (`IsomorphicTest`), and
the deliberate bad cast in `HeapIntersectionTest.checkFamilyID`.
- `deprecated-call` in tests, and `uncaught-number-format-exception` in
`FrequentLongsSketch.getInstance(String)`, which other open work already
touches. A `NumberFormatException` is an `IllegalArgumentException` in any case.
## Testing
`mvn verify`: 2320 tests, 0 failures. The CodeQL run on this PR will show
which alerts close.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]