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

Viewed 22759

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$'.

2 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.

I think by the convention, your StreetOwner("0"), StreetedBy("1"), StreetedFor("2"), RegisteredBy("3"), StreetContact("4"), AssignedTo("5"); All of these should be in capital letter for all character.

Related