S3066 FP public field in enum declared final

Windows using Eclipse with SolarLint 7.9.0.66038 for Java

An enum with a false positive on the field ‘permissions’ as show below with java:S3066
Should not flag fields that are ‘final’.

public enum Authorization
{  
    Never("NonExistingPermissionToPreventAuthorization");
  
    public final String[] permissions;
  
    Authorization(String...permissions)
    { this.permissions = permissions; }
  
    Authorization(Authorization subAuthorization, String...permissions)
    { this.permissions = Helper.combine(subAuthorization.permissions, permissions); }
}

Hey @dandoy,

Thanks for the feedback but in this case, I am not sure this is a false positive.

While the field is marked as final and cannot be reassigned null or another array, the value at permissions[0] can be modified at will after the creation of the enum.

System.out.println(Authorization.Never.permissions[0]); // NonExistingPermissionToPreventAuthorization
Authorization.Never.permissions[0] = "Hello, World!";
System.out.println(Authorization.Never.permissions[0]); // Hello, World!
Authorization.Never.permissions[0] = null;
System.out.println(Authorization.Never.permissions[0]); // null

The visibility might be intended for Helper.combine to be able to manipulate the arrays but maybe you could consider using an immutable data structure instead of an array?

Cheers,

Dorian