FN about the rule S1068

Lombok annotation @Log can introduce a private field logger and this field could be forgotten to use, for example, in the following program, the annotation can generate a unused private field logger and S1068 should report a warning.

import lombok.extern.java.Log;

@Log
public class Example {
  public static void main(String... args) {
    Sytem.exit(0);
  }
}

SonarQube version: 9.7.1

1 Like

Hello @sa-research thanks for your message.

To understand why the analyzer behaves a certain way you should keep in mind that it analyzes your source code. In the source code, there is no variable, as it only appears in the bytecode, thus it is not applicable to the rule.

However, you are right that this code contains a useless annotation. So it could be a nice idea for the new rule to find such annotations and report on them. I Hope, this answers your question.

Regards,
Matgarita