Skip to content

refactor: improve code quality in ASTChain and OgnlContext#502

Merged
lukaszlenart merged 1 commit intomainfrom
refactor/sonarcloud-code-quality-improvements
Nov 29, 2025
Merged

refactor: improve code quality in ASTChain and OgnlContext#502
lukaszlenart merged 1 commit intomainfrom
refactor/sonarcloud-code-quality-improvements

Conversation

@lukaszlenart
Copy link
Copy Markdown
Collaborator

@lukaszlenart lukaszlenart commented Nov 29, 2025

Summary

Address multiple SonarCloud code quality issues in ASTChain and OgnlContext classes:

  • Add missing @Override annotations (java:S1161) - Ensures proper method override documentation
  • Use pattern matching for instanceof (java:S6201) - Leverages Java 16+ pattern matching for cleaner code
  • Reduce cognitive complexity (java:S3776) - Simplifies nested conditions in ASTChain for better readability
  • Extract string literals as constants (java:S1192) - Defines CURRENT_CHAIN and LAST_CHILD constants in OgnlContext
  • Improve exception handling - Changes from catching Throwable to Exception
  • Code readability improvements - Uses isEmpty() instead of length checks, better variable naming

Files Changed

  • ognl/src/main/java/ognl/ASTChain.java - Refactored for reduced complexity and modern Java patterns
  • ognl/src/main/java/ognl/OgnlContext.java - Added constants for magic strings

Test Plan

  • Verify full test suite passes (607 tests)
  • Run SonarCloud analysis to confirm issues are resolved
  • Verify no regressions in existing functionality
  • Check code coverage remains stable

🤖 Generated with Claude Code

Address multiple SonarCloud code quality issues:

- Add missing @OverRide annotations (java:S1161)
- Use pattern matching for instanceof (java:S6201)
- Reduce cognitive complexity by simplifying nested conditions (java:S3776)
- Extract string literals "_currentChain" and "_lastChild" as constants (java:S1192)
- Improve exception handling by catching Exception instead of Throwable
- Improve code readability with isEmpty() and better variable naming

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <[email protected]>
@sonarqubecloud
Copy link
Copy Markdown

Quality Gate Failed Quality Gate failed

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

See analysis details on SonarQube Cloud

@lukaszlenart lukaszlenart marked this pull request as ready for review November 29, 2025 12:20
@lukaszlenart lukaszlenart merged commit 3474589 into main Nov 29, 2025
4 of 5 checks passed
@lukaszlenart lukaszlenart deleted the refactor/sonarcloud-code-quality-improvements branch November 29, 2025 12:35
@lukaszlenart lukaszlenart added this to the 3.5.0 milestone Nov 29, 2025
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