Skip to content

chore: clear SonarCloud code smells - #32

Merged
kazemek merged 2 commits into
mainfrom
chore/clear-sonarcloud-issues
Aug 2, 2026
Merged

kazemek merged 2 commits into
mainfrom
chore/clear-sonarcloud-issues

Conversation

@kazemek

@kazemek kazemek commented Aug 2, 2026 •

Copy link
Copy Markdown
Collaborator

Satisfy null-flow, record-pattern, and literal-duplication rules so new_violations returns to zero under the project quality policy.

Summary by CodeRabbit

  • Bug Fixes

    • Corrected to-many relationship serialization for arrays, producing one collection entry per valid item.
    • Null elements in relationship arrays are now skipped safely.
    • Improved handling of null to-one relationship values during serialization.
    • Preserved consistent validation paths for relationships, links, and document data.
  • Refactor

    • Simplified serialization and mapping logic while maintaining existing output and behavior.
  • Documentation

    • Added documentation to an internal constructor for improved maintainability.

Satisfy null-flow, record-pattern, and literal-duplication rules so
new_violations returns to zero under the project quality policy.
@coderabbitai

coderabbitai Bot commented Aug 2, 2026 •

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: f2b5a7df-3fd3-46b2-a950-1e61c8e90a73

📥 Commits

Reviewing files that changed from the base of the PR and between 6d257a4 and e93482f.

📒 Files selected for processing (2)
  • jsonapi-java-jackson3/src/main/java/io/github/kazemek/jsonapi/jackson3/internal/DomainResourceWriter.java
  • jsonapi-java-jackson3/src/test/groovy/io/github/kazemek/jsonapi/jackson3/ResourceMappingJacksonFeaturesSpec.groovy
🚧 Files skipped from review as they are similar to previous changes (1)
  • jsonapi-java-jackson3/src/main/java/io/github/kazemek/jsonapi/jackson3/internal/DomainResourceWriter.java

📝 Walkthrough

Walkthrough

The change centralizes validation paths and document parameter names. It refactors Jackson wire serialization and relationship conversion, adds coverage for null array elements, then simplifies mapping exception handling and documents existing constructor initialization.

Changes

Validation and Jackson codec

Layer / File(s) Summary
Validation path and parameter constants
jsonapi-java-core/.../JsonApiDocumentValidator.java, jsonapi-java-jackson3/.../JsonApiDocumentWriter.java, jsonapi-java-jackson3/.../internal/DocumentWireReader.java, jsonapi-java-jackson3/.../internal/LinkWireReader.java
Shared constants replace repeated relationship, data, links, and document parameter literals.
Wire serialization and relationship conversion
jsonapi-java-jackson3/.../internal/JsonApiWireWriter.java, jsonapi-java-jackson3/.../internal/DomainResourceWriter.java, jsonapi-java-jackson3/src/test/groovy/.../ResourceMappingJacksonFeaturesSpec.groovy
Serialization code caches values before checks and uses record patterns. Relationship conversion rejects null to-one fallback values, preserves array elements, and tests leading-null identifier arrays.
Mapping and location-index cleanup
jsonapi-java-jackson3/.../internal/MappingDefinitionCache.java, jsonapi-java-jackson3/.../internal/ReadLocationIndex.java
Mapping computation removes a redundant exception wrapper. The location-index constructor documents its existing initialization behavior.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Possibly related PRs

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately summarizes the PR's primary goal of resolving SonarCloud code smells.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches 💡 1
📝 Generate docstrings 💡
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch chore/clear-sonarcloud-issues

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai 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.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In
`@jsonapi-java-jackson3/src/main/java/io/github/kazemek/jsonapi/jackson3/internal/DomainResourceWriter.java`:
- Around line 253-255: Update the Object[] branch in the value conversion switch
used before classifyToManyItems to use a null-tolerant list conversion instead
of List.of(array). Preserve null elements so classifyToManyItems can skip them,
while leaving the existing List<?> handling unchanged.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: 7ab87220-026a-430d-bd87-d41f121544e2

📥 Commits

Reviewing files that changed from the base of the PR and between 0ff5e7f and 6d257a4.

📒 Files selected for processing (8)
  • jsonapi-java-core/src/main/java/io/github/kazemek/jsonapi/core/validation/JsonApiDocumentValidator.java
  • jsonapi-java-jackson3/src/main/java/io/github/kazemek/jsonapi/jackson3/JsonApiDocumentWriter.java
  • jsonapi-java-jackson3/src/main/java/io/github/kazemek/jsonapi/jackson3/internal/DocumentWireReader.java
  • jsonapi-java-jackson3/src/main/java/io/github/kazemek/jsonapi/jackson3/internal/DomainResourceWriter.java
  • jsonapi-java-jackson3/src/main/java/io/github/kazemek/jsonapi/jackson3/internal/JsonApiWireWriter.java
  • jsonapi-java-jackson3/src/main/java/io/github/kazemek/jsonapi/jackson3/internal/LinkWireReader.java
  • jsonapi-java-jackson3/src/main/java/io/github/kazemek/jsonapi/jackson3/internal/MappingDefinitionCache.java
  • jsonapi-java-jackson3/src/main/java/io/github/kazemek/jsonapi/jackson3/internal/ReadLocationIndex.java

List.of rejected null array elements before classifyToManyItems could
skip them; Arrays.asList keeps List/Iterable null-skipping behavior.
@kazemek

kazemek commented Aug 2, 2026

Copy link
Copy Markdown
Collaborator Author

Addressed the actionable CodeRabbit finding in e93482f (Arrays.asList for Object[] + array null regression test).

Skipping the docstring-coverage pre-merge warning — this repo has no docstring gate, and this PR is Sonar smell cleanup only.

@sonarqubecloud

sonarqubecloud Bot commented Aug 2, 2026

Copy link
Copy Markdown

@kazemek
kazemek merged commit b3c3f9c into main Aug 2, 2026
3 checks passed
@kazemek
kazemek deleted the chore/clear-sonarcloud-issues branch August 2, 2026 19:14
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.

1 participant