FPs for fields when using Lombok @UtilityClass

On SonarCloud, SonarJava raises false positives when using Lombok @UtilityClass, which (among other things) automatically makes all fields static:

import lombok.experimental.UtilityClass;

public class SomeConstants
    // S1170: Make this final field static too.
    // S00116: Rename this field "MY_CONSTANT" to match the regular expression '^[a-z][a-zA-Z0-9]*$'.
    public final int MY_CONSTANT = 123;

I have prepared a patch for this and will create a PR shortly.

Here’s the pull request: https://github.com/SonarSource/sonar-java/pull/2207

Hey @bannmann,

Thanks for the feedback and the PR. I created the corresponding JIRA ticket to handle it: SONARJAVA-2923.

I edited the title of your PR to match the ticket, and added my review.


1 Like