On SonarCloud, SonarJava raises false positives for regex Patterns when using Lombok @UtilityClass.
S4248 requires compiled patterns to be assigned to constants, but does not recognize the static
keyword generated by @UtilityClass
.
Example:
import java.util.regex.Pattern;
import lombok.experimental.UtilityClass;
@UtilityClass
public class Foo
{
// S4248: Refactor this code to use a "static final" Pattern.
private final Pattern PATTERN = Pattern.compile(".*");
}