Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

SonarQube issue: Rename this constant name to match the regular expression '^[A-Z][A-Z0-9](_[A-Z0-9]+)$'

I have created this enum class

public enum StreetNameEnum {
  StreetOwner("0"), StreetedBy("1"), StreetedFor("2"), RegisteredBy("3"), StreetContact("4"), AssignedTo("5");
  private String code;
  StreetRoleEnum(String code) {}
  public String getCode() {
    return code;
  }
}

SonarQube issue:

Rename this constant name to match the regular expression '^[A-Z]A-Z0-9$'.

like image 564
Sandro Rey Avatar asked Oct 17 '19 08:10

Sandro Rey


1 Answers

It means your constants are supposed to match this regular expression:

^[A-Z][A-Z0-9](_[A-Z0-9]+)$

Which basically means, only use upper case characters, numbers and underscores (in the order which is valid Java syntax). So instead of StreetOwner, use STREET_OWNER. RegisteredBy should be REGISTERED_BY and so forth.

like image 73
Elias Avatar answered Nov 02 '22 10:11

Elias