# False positive on missing constructor for classes with Lombok’s @Builder annotation

**URL:** <https://community.sonarsource.com/t/false-positive-on-missing-constructor-for-classes-with-lombok-s-builder-annotation/55558>\
**Category:** Report False-positive / False-negative...\
**Tags:** lombok, sonarqube-ide, java\
**Created:** [December 24, 2021, 2:21pm UTC](https://community.sonarsource.com/t/false-positive-on-missing-constructor-for-classes-with-lombok-s-builder-annotation/55558 "2021-12-24T14:21:08Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Nikhilrao](https://avatars.discourse-cdn.com/v4/letter/n/bc79bd/32.png) [@Nikhilrao](https://community.sonarsource.com/u/Nikhilrao)\
**Post date:** [December 24, 2021, 2:21pm UTC](https://community.sonarsource.com/t/false-positive-on-missing-constructor-for-classes-with-lombok-s-builder-annotation/55558/1 "2021-12-24T14:21:08Z")

</div>

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](https://projectlombok.org/features/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

```auto
@Builder //[S1258] SonarLint: Add a constructor to the class, or provide default values.
@JsonDeserialize(builder = Test.TestBuilder.class)
@JsonIgnoreProperties(ignoreUnknown = true)
public class Test {
}

```

---

<div class="post-metadata">

**Author:** ![Quentin](https://dub1.discourse-cdn.com/sonarsource/user_avatar/community.sonarsource.com/quentin/32/74716_2.png) [@Quentin](https://community.sonarsource.com/u/Quentin)\
**Post date:** [January 3, 2022, 4:55pm UTC](https://community.sonarsource.com/t/false-positive-on-missing-constructor-for-classes-with-lombok-s-builder-annotation/55558/3 "2022-01-03T16:55:53Z")

</div>

Hello @Nikhilrao and welcome to the community!

I agree that the issue should not be raised. My first observation is that we are not supporting `@SuperBuilder`, I created a ticket for that: [SONARJAVA-4117](https://jira.sonarsource.com/browse/SONARJAVA-4117).

But I’m still confused to see that `@Builder` is raising an issue, we should support it. Could you confirm that you are indeed using `@Builder` and that your project was correctly built and dependencies were correctly resolved?

---

<div class="post-metadata">

**Author:** ![system](https://dub1.discourse-cdn.com/sonarsource/user_avatar/community.sonarsource.com/system/32/31083_2.png) [@system](https://community.sonarsource.com/u/system)\
**Post date:** [February 28, 2022, 4:52pm UTC](https://community.sonarsource.com/t/false-positive-on-missing-constructor-for-classes-with-lombok-s-builder-annotation/55558/5 "2022-02-28T16:52:56Z")

</div>

Closed on February 28, 2022, 4:52pm UTC

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.
