style: format imports across multiple files - #5200
Conversation
|
Tick the box to add this pull request to the merge queue (same as
|
Not up to standards ⛔🔴 Issues
|
| Category | Results |
|---|---|
| CodeStyle | 1 minor |
🟢 Metrics 10 complexity
Metric Results Complexity 10
NEW Get contextual insights on your PRs based on Codacy's metrics, along with PR and Jira context, without leaving GitHub. Enable AI reviewer
TIP This summary will be updated as you push new changes.
| <dependency> | ||
| <groupId>jakarta.annotation</groupId> | ||
| <artifactId>jakarta.annotation-api</artifactId> | ||
| <version>1.3.5</version> | ||
| <scope>provided</scope> | ||
| </dependency> |
There was a problem hiding this comment.
Code Review
This pull request modernizes the codebase by adopting Java 21 features, such as pattern matching for instanceof, List.getFirst(), and List.getLast(), alongside refactoring collection initializations to use Map.of() and List.of(). While these changes improve readability, the code review correctly identifies several critical issues where replacing HashMap or LinkedHashMap with Map.of() breaks insertion-order guarantees required for wire equality, or risks throwing NullPointerException due to potential null values. Additionally, some refactorings introduce unnecessary allocation overhead in performance-sensitive paths.
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.
| final Map<String, Object> metadata = Map.of( | ||
| "server", "Neo4j/5.26.0 compatible (ArcadeDB " + Constants.getRawVersion() + ")", | ||
| "connection_id", "bolt-" + Thread.currentThread().threadId()); |
There was a problem hiding this comment.
The comment explicitly states that the insertion order of the metadata is significant for wire equality. Replacing the LinkedHashMap with Map.of() breaks this guarantee because Map.of() has a randomized iteration order in Java. This will cause random failures in wire equality checks.
| final Map<String, Object> metadata = Map.of( | |
| "server", "Neo4j/5.26.0 compatible (ArcadeDB " + Constants.getRawVersion() + ")", | |
| "connection_id", "bolt-" + Thread.currentThread().threadId()); | |
| final Map<String, Object> metadata = new LinkedHashMap<>(); | |
| metadata.put("server", "Neo4j/5.26.0 compatible (ArcadeDB " + Constants.getRawVersion() + ")"); | |
| metadata.put("connection_id", "bolt-" + Thread.currentThread().threadId()); |
| final Map<String, Object> result = new HashMap<>(Map.of( | ||
| "value", maxValue, | ||
| "items", maxItems)); |
There was a problem hiding this comment.
Using Map.of() here will throw a NullPointerException if maxValue is null. In this method, maxValue is initialized to null and can remain null if no non-null items are processed. Map.of() does not permit null values.
| final Map<String, Object> result = new HashMap<>(Map.of( | |
| "value", maxValue, | |
| "items", maxItems)); | |
| final Map<String, Object> result = new HashMap<>(); | |
| result.put("value", maxValue); | |
| result.put("items", maxItems); |
| final Map<String, Object> result = new HashMap<>(Map.of( | ||
| "value", minValue, | ||
| "items", minItems)); |
There was a problem hiding this comment.
Using Map.of() here will throw a NullPointerException if minValue is null. In this method, minValue is initialized to null and can remain null if no non-null items are processed. Map.of() does not permit null values.
| final Map<String, Object> result = new HashMap<>(Map.of( | |
| "value", minValue, | |
| "items", minItems)); | |
| final Map<String, Object> result = new HashMap<>(); | |
| result.put("value", minValue); | |
| result.put("items", minItems); |
| final Map<String, Object> vRel = new HashMap<>(Map.of( | ||
| "_type", "vRelationship", | ||
| "_id", "vRel:" + (++virtualIdCounter), | ||
| "_relType", type, | ||
| "_start", getNodeId(fromNode), | ||
| "_end", getNodeId(toNode))); |
There was a problem hiding this comment.
Using Map.of() here will throw a NullPointerException if getNodeId(fromNode) or getNodeId(toNode) returns null. getNodeId() explicitly returns null if the input node is null or does not match any expected type. Map.of() does not permit null values.
| final Map<String, Object> vRel = new HashMap<>(Map.of( | |
| "_type", "vRelationship", | |
| "_id", "vRel:" + (++virtualIdCounter), | |
| "_relType", type, | |
| "_start", getNodeId(fromNode), | |
| "_end", getNodeId(toNode))); | |
| final Map<String, Object> vRel = new HashMap<>(); | |
| vRel.put("_type", "vRelationship"); | |
| vRel.put("_id", "vRel:" + (++virtualIdCounter)); | |
| vRel.put("_relType", type); | |
| vRel.put("_start", getNodeId(fromNode)); | |
| vRel.put("_end", getNodeId(toNode)); |
| final Map<String, Object> map = new HashMap<>(Map.ofEntries( | ||
| Map.entry("writeTx", writeTx.get()), | ||
| Map.entry("readTx", readTx.get()), | ||
| Map.entry("txRollbacks", txRollbacks.get()), | ||
| Map.entry("createRecord", createRecord.get()), | ||
| Map.entry("readRecord", readRecord.get()), | ||
| Map.entry("updateRecord", updateRecord.get()), | ||
| Map.entry("deleteRecord", deleteRecord.get()), | ||
| Map.entry("existsRecord", existsRecord.get()), | ||
| Map.entry("queries", queries.get()), | ||
| Map.entry("commands", commands.get()), | ||
| Map.entry("scanType", scanType.get()), | ||
| Map.entry("scanBucket", scanBucket.get()), | ||
| Map.entry("iterateType", iterateType.get()), | ||
| Map.entry("iterateBucket", iterateBucket.get()), | ||
| Map.entry("countType", countType.get()), | ||
| Map.entry("countBucket", countBucket.get()))); |
There was a problem hiding this comment.
Replacing the direct HashMap population with new HashMap<>(Map.ofEntries(...)) introduces significant performance and memory overhead. It allocates 16 KeyValueHolder objects, an array of size 16, an immutable map, and then copies them into a new HashMap. Reverting to new HashMap<>() and calling put() avoids all these intermediate allocations, which is crucial for a stats-gathering method that may be called frequently.
| final Map<String, Object> map = new HashMap<>(Map.ofEntries( | |
| Map.entry("writeTx", writeTx.get()), | |
| Map.entry("readTx", readTx.get()), | |
| Map.entry("txRollbacks", txRollbacks.get()), | |
| Map.entry("createRecord", createRecord.get()), | |
| Map.entry("readRecord", readRecord.get()), | |
| Map.entry("updateRecord", updateRecord.get()), | |
| Map.entry("deleteRecord", deleteRecord.get()), | |
| Map.entry("existsRecord", existsRecord.get()), | |
| Map.entry("queries", queries.get()), | |
| Map.entry("commands", commands.get()), | |
| Map.entry("scanType", scanType.get()), | |
| Map.entry("scanBucket", scanBucket.get()), | |
| Map.entry("iterateType", iterateType.get()), | |
| Map.entry("iterateBucket", iterateBucket.get()), | |
| Map.entry("countType", countType.get()), | |
| Map.entry("countBucket", countBucket.get()))); | |
| final Map<String, Object> map = new HashMap<>(); | |
| map.put("writeTx", writeTx.get()); | |
| map.put("readTx", readTx.get()); | |
| map.put("txRollbacks", txRollbacks.get()); | |
| map.put("createRecord", createRecord.get()); | |
| map.put("readRecord", readRecord.get()); | |
| map.put("updateRecord", updateRecord.get()); | |
| map.put("deleteRecord", deleteRecord.get()); | |
| map.put("existsRecord", existsRecord.get()); | |
| map.put("queries", queries.get()); | |
| map.put("commands", commands.get()); | |
| map.put("scanType", scanType.get()); | |
| map.put("scanBucket", scanBucket.get()); | |
| map.put("iterateType", iterateType.get()); | |
| map.put("iterateBucket", iterateBucket.get()); | |
| map.put("countType", countType.get()); | |
| map.put("countBucket", countBucket.get()); |
ba6bb22 to
fb56988
Compare
|
Automated review: OpenRewrite cleanup PR Thanks for driving a codebase-wide cleanup - centralizing this in an OpenRewrite recipe is a nice, repeatable approach. That said, the size and true scope of this PR raise several concerns worth addressing before merge. 1. CI is currently red (blocker) 2. Title/scope understate what this does
3. Please split this PR
4. Non-reproducible plugin version 5. Wildcard imports introduced (~130 net new) 6. jakarta.annotation-api and the license failure
7. Minor pom nits
Summary Automated review; a human maintainer should confirm before merging. |
What does this PR do?
A brief description of the change being made with this pull request.
Motivation
What inspired you to submit this pull request?
Related issues
A list of issues either fixed, containing architectural discussions, otherwise relevant
for this Pull Request.
Additional Notes
Anything else we should know when reviewing?
Checklist
mvn clean packagecommand