java:S6857 reporting for #{ expression using a variable

  • Java
  • java:S6857
  • SonarQube Server Enterprise Edition v10.8.1 (101195)

I have a spring boot project
in properties file I have

app.pagination.limit=10
provider.attribute_map={\
	'givenname': 'firstName', \
	'sn': 'lastName' \
}

In a Java class

@Value("#{T(java.lang.Math).min(50, ${app.pagination.limit})}")
private int paginationLimit;

@Value("#{${provider.attribute_map:T(java.util.Collections).emptyMap()}}")
Map<String, String> attributeMap;

The SPEL is properly evaluated assigning the variable to 10, but sonar is reporting “Correct this malformed SpEL expression.”

Hey there.

This is a known issue in progress of being fixed. SONARJAVA-4917

It should be fixed with SonarQube Server 2025.3, coming later this month.

(!) Your version is past EOL. You should upgrade to either the latest version or the current LTA (long-term active version) at your earliest convenience. Your upgrade path is:

10.8 → 2025.1.1-> 2025.2 (last step optional)

You may find these resources helpful:

1 Like