Possible false positive on rule "Classes and enums with private members should have a constructor"

Hello,

I have a Spring @Service Java class with 2 properties that are initialized by means of a @Value annotation. In the @Value annotation I specify a default value. However rule java:S1258 triggers, although I think it should not:

Message: “Add a constructor to the class, or provide default values”.

Is my understanding correct or does the rule raise a false-positive issue?

I am using:

  • SonarQube for IDE 11.6.0.83783
  • IntelliJ 2025.3
  • Windows
  • SonarQube Community v25.7.0.110598

Hi Ivan,

Thank you for the report! Yes, this a false positive. I created a ticket, SONARJAVA-5929, to fix this issue.

Hello Tomasz, thank you for your feedback!