Sonar Lint Code smell S1258 says “Classes and enums with private members should have a constructor (java:S1258)”
But there are some exclusions to this rule . The first exclusion is "Class implementing a Builder Pattern (name ending with “Builder”). "
I am using Lombok’s @Builder annotation in my pojo . As the specification says , it generates an allArgsConstructor .
So my question here is is there any need to create a default constructor for my pojo class for this sonar rule to go away.?
I feel this sonar rule with lombok’s @Builder or @SuperBuilder annotations is a false positive.
Versions used:
- MyEclipse Enterprise Version: 2021.5.24
- SonarLint plugin for MyEclipse . Version - 7.1
- JDK 11
- lombok 1.18.22
Sample Code
@Builder //[S1258] SonarLint: Add a constructor to the class, or provide default values.
@JsonDeserialize(builder = Test.TestBuilder.class)
@JsonIgnoreProperties(ignoreUnknown = true)
public class Test {
}