java:S2637 "@NonNull" values should not be set to null false positive with lombok @NonNull generated setter

Sonar report the bug java:S2637 while there is no one as constructor initialize non null property

@Data
@NoArgsConstructor(access = AccessLevel.PROTECTED)
public class UserLink implements Serializable {

    private Long id;
    private Type type;
    @lombok.NonNull 
    private User user;

    public UserLink(User user) {
        this.setUser(user);
    }
 
}

Hello @hibour

Late answer to tell you that a ticket is in fact already created for a similar issue: SONARJAVA-3695.

I made sure to add a comment with your example to make sure it will be taken into consideration when working on the ticket.

Best,
Quentin

1 Like

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