I'm having an issue with SonarQube while using public static
variables, the problem is that SonarQube want that to be public static final
, this variable is being filled in other parts of the code, it is "dynamically" (filled with environment variable) then is used in all other classes.
This is the arrayList variable
public static List<String> listPersons = new ArrayList<>();
Errors by Sonar:
1- Make this "public static listPersons" field final
2- Make listPersons a static final constant or non-public and provide accessors if needed
3- Make this member "protected"
What's the best approach to fix this problem?