Skip to content

fix: clear Sonar maintainability findings - #56

Merged
ohbus merged 3 commits into
masterfrom
fix/sonar-followup
Nov 2, 2026
Merged

ohbus merged 3 commits into
masterfrom
fix/sonar-followup

Conversation

@ohbus

@ohbus ohbus commented Oct 30, 2026 •

Copy link
Copy Markdown
Owner
  • Remove impossible generic Exception declarations from SecurityConfig.
  • Keep the controller test lambda to one potentially-throwing call.
  • Share the common post association mapping between Likes and HashtagPosts.

Summary by CodeRabbit

  • Refactor
    • Standardized how hashtag and like records are associated with posts, improving consistency without changing user-facing behavior.
  • Maintenance
    • Updated code quality scan settings and simplified security configuration declarations. These changes do not alter app behavior.
  • Tests
    • Clarified test coverage for malformed and unknown user identifiers; expected error responses remain unchanged.

@coderabbitai

coderabbitai Bot commented Oct 30, 2026 •

Copy link
Copy Markdown

Review in Change Stack →

No actionable comments were generated in the recent review.

Recent review info
Run configuration
  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI
  • Review profile: ASSERTIVE
  • Plan: Advanced
  • Run ID: 2ae956d4-dd03-4ce2-aa8d-2ef3bc05c86c
Commits

Reviewing files that changed from the base of the PR and between a8c614d and 99a1f95.

Files selected for processing: 6
  • .github/workflows/sonar-fork.yml
  • src/main/java/xyz/subho/clone/twitter/entity/HashtagPosts.java
  • src/main/java/xyz/subho/clone/twitter/entity/Likes.java
  • src/main/java/xyz/subho/clone/twitter/entity/PostAssociation.java
  • src/main/java/xyz/subho/clone/twitter/security/SecurityConfig.java
  • src/test/java/xyz/subho/clone/twitter/controller/UserControllerTest.java

Included review availability: This review used your included allowance. Your plan provides up to 1 included review per hour; 0 remain after this review.

Walkthrough

The change adds a shared mapped superclass for post associations and updates two entities to use it. It also adds Sonar coverage exclusions, removes exception declarations from two security methods, and reuses a UUID string in a test.

Changes: Post association reuse

Layer / File(s) Summary
Define shared post association
src/main/java/xyz/subho/clone/twitter/entity/PostAssociation.java
PostAssociation extends Auditable and defines the lazy Posts association, its column mapping, and public accessors.
Use shared association
src/main/java/xyz/subho/clone/twitter/entity/HashtagPosts.java, src/main/java/xyz/subho/clone/twitter/entity/Likes.java
HashtagPosts and Likes now extend PostAssociation. Both entities remove their local posts relationship and accessors.

Security method signatures

Layer / File(s) Summary
Update security method signatures
src/main/java/xyz/subho/clone/twitter/security/SecurityConfig.java
securityFilterChain and authenticationManager no longer declare throws Exception. Their method bodies remain unchanged.

Sonar coverage exclusions

Layer / File(s) Summary
Configure coverage exclusions
.github/workflows/sonar-fork.yml
The Sonar workflow excludes entity and model paths, mapper implementations, the application entry point, Mockito mock classes, and auxiliary classes from coverage.

UUID test cleanup

Layer / File(s) Summary
Reuse UUID string in test
src/test/java/xyz/subho/clone/twitter/controller/UserControllerTest.java
The UUID lookup stubs and not-found assertion use a stored UUID string. The expected exception remains ResourceNotFoundException.

Priority: Low

Estimated code review effort: 2 (Simple) | ~10 minutes

Change: Refactor

Possibly related PRs

  • ohbus/twitter-backend-java#55: Adds the lookupRejectsMalformedAndUnknownIdentities test that this change edits, and also updates Sonar coverage exclusions.
Merge Risk: Minimal · up to 99a1f

No concrete defect or unresolved merge risk is established by this change.

Pre-merge checks: Passed 5
Check name Status Explanation
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check Passed The title clearly identifies the primary objective: resolving Sonar maintainability findings. The changes include Sonar configuration updates and code refactoring related to maintainability.
Docstring Coverage Passed No eligible functions found in the changed files. Skipping docstring coverage check. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documentat…
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.
Full details: Docstring Coverage

Explanation

No eligible functions found in the changed files. Skipping docstring coverage check. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documentation-only edits and deletions within surviving functions are included; unchanged diff context and fully deleted functions are excluded. Analyzed 0 functions across 5 files. (1 skipped: 1 unsupported.)

Finishing Touches
📝 Generate docstrings
  • Commit to this branch
  • Create a new PR
🧪 Generate unit tests (beta)
  • Commit to this branch
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

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

@sonarqubecloud

Copy link
Copy Markdown

Quality Gate Failed Quality Gate failed

Failed conditions
0.0% Coverage on New Code (required ≥ 80%)

See analysis details on SonarQube Cloud

@ohbus
ohbus merged commit 3f4500a into master Nov 2, 2026
4 checks passed
@ohbus
ohbus deleted the fix/sonar-followup branch November 2, 2026 12:16
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