Skip to content

SONARJAVA-4917 S6857 support property placeholder inside SpEL#5128

Merged
erwan-serandour merged 13 commits intomasterfrom
erwan/S6857
May 6, 2025
Merged

SONARJAVA-4917 S6857 support property placeholder inside SpEL#5128
erwan-serandour merged 13 commits intomasterfrom
erwan/S6857

Conversation

@erwan-serandour
Copy link
Copy Markdown
Contributor

@erwan-serandour erwan-serandour commented May 5, 2025

Comment thread java-checks/src/main/java/org/sonar/java/checks/spring/SpelExpressionCheck.java Outdated
Comment thread java-checks/src/main/java/org/sonar/java/checks/spring/SpelExpressionCheck.java Outdated
Comment thread java-checks/src/main/java/org/sonar/java/checks/spring/SpelExpressionCheck.java Outdated
Comment thread java-checks/src/main/java/org/sonar/java/checks/spring/SpelExpressionCheck.java Outdated
Comment thread java-checks/src/main/java/org/sonar/java/checks/spring/SpelExpressionCheck.java Outdated
Comment thread java-checks/src/main/java/org/sonar/java/checks/spring/SpelExpressionCheck.java Outdated
Comment thread java-checks/src/main/java/org/sonar/java/checks/spring/SpelExpressionCheck.java Outdated
@erwan-serandour erwan-serandour changed the title SONARJAVA-4917 support property placeholder inside SpEL SONARJAVA-4917 S6857 support property placeholder inside SpEL May 6, 2025
@erwan-serandour erwan-serandour requested a review from Copilot May 6, 2025 10:03
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This pull request implements support for property placeholders inside SpEL expressions to address SONARJAVA-4917. Key changes include refactoring the string content checking methods to use a new ParseCtx, introducing new record types (Range, Placeholder, and ParseCtx), and updating error messaging and parsing logic for property placeholders and SpEL expressions.

Reviewed Changes

Copilot reviewed 2 out of 3 changed files in this pull request and generated no comments.

File Description
java-checks/src/main/java/org/sonar/java/checks/spring/SpelExpressionCheck.java Refactored parsing logic and error reporting for property placeholders and SpEL expressions using new types and methods.
java-checks-test-sources/default/src/main/java/checks/spring/SpelExpressionCheckSample.java Updated test cases to reflect the new parsing behavior and error messages for property placeholders inside SpEL.
Files not reviewed (1)
  • its/autoscan/src/test/resources/autoscan/diffs/diff_S6857.json: Language not supported
Comments suppressed due to low confidence (2)

java-checks/src/main/java/org/sonar/java/checks/spring/SpelExpressionCheck.java:188

  • [nitpick] Consider rephrasing the exception message to improve clarity and grammatical correctness (e.g., 'Range must be non-empty; start value must be less than end value.').
if (start >= end) { throw new IllegalArgumentException("a range is must be non empty, this imply start must be less than end"); }

java-checks-test-sources/default/src/main/java/checks/spring/SpelExpressionCheckSample.java:447

  • [nitpick] Consider renaming 'PropertyPlaceHolderInsideSpEL' to 'PropertyPlaceholderInsideSpEL' for consistency in capitalization.
static class PropertyPlaceHolderInsideSpEL {

throw new SyntaxError("Correct this malformed property placeholder.", range.addOffset(offset));
}
}
private record ParseCtx(String expressionSource, int offset) {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

add a bit of doc here, in particular what's the offset

@sonarqube-next
Copy link
Copy Markdown

sonarqube-next Bot commented May 6, 2025

@erwan-serandour erwan-serandour merged commit 85f296e into master May 6, 2025
14 of 15 checks passed
@erwan-serandour erwan-serandour deleted the erwan/S6857 branch May 6, 2025 13:05
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.

3 participants