Sonar warning S6857: Correct this malformed property placeholder - is this a false positive?

304 Views Asked by At

I have a very simple spring boot configuration class like this:

@Getter
@Configuration
public class SomeConfig {
    @Value("${some.property:some default if property is unset}")
    private String someProperty;
}

This works. If some.property is set, someProperty is set to this value - otherwise it's set to the default.

But recently both SonarLint and SonarCloud have started complaining:

Correct this malformed property placeholder.

SpEL expression should have a valid syntax java:S6857

(removing the spaces removes the warning - but removing them would be wrong)

Before I close this as a false positive, I'd like to know if my analysis is correct: According to the @Value javadoc, the value passed to @Value is either a SpEL expression or a property injected via ${}. But validating the latter with rules for the former is doomed to fail. Is this correct?

0

There are 0 best solutions below