False Positive with Java and Lombok

Product: SonarQube Enterprise
Version: 7.9.5
Language: Java

We have identified some false positives when we are using Lombok.
We had a look around and found this in StackOverflow which advices it would be better to change the rules, rather than mark the issues as a false positive every time.

Why we believe it’s a false-positive?
Rule is complaining the variables are never used, the reason is that the getters and setters that do use them are added by Lombok, hence not visible in the source code.

A code sample
False positive can be seen here on the report

package uk.gov.defra.reach.nipnots.client;

import java.util.UUID;
import lombok.Data;

@Data

public class LegalEntityDetails {

  private UUID accountId;
*Remove this unused "accountId" private field.See Rule*
*last month*

This should be enough code to trigger the warning though

import java.util.UUID;
import lombok.Data;

@Data
public class LegalEntityDetails {
  private UUID accounted; // Remove this unused "accountId" private field.
}

We can’t easily share our code base this way – do you need all that to test the simple class above? If so I will have to put aside some time to set something up.

Hello @jgaskellDEFRA, and welcome to the SonarSource community.

According to my tests, what is stated in the accepted answer in the StackOverflow post you linked is still relevant. You may want to have a look in this direction.

Let us know if it solves your problem!