Ruchira Gayan Ranaweera
Ruchira Gayan Ranaweera

Reputation: 35557

Solution for following sonar Issue?

following line of code in my code segment detected as an Issue by sonar.

code segment:

final int Pending=1; 

sonar Issue:

             Name 'Pending' must match pattern '^[a-z][a-zA-Z0-9]*$'.

why sonar detect this as an issue?

Upvotes: 2

Views: 14147

Answers (1)

Well, Sonar gives an explicit message for the violation: the variable "Pending" does not match the given regexp pattern "^[a-z][a-zA-Z0-9]*$". This pattern means: any string that begins with a lowercase letter, followed by any letters or digits. So your variable should be called "pending", not "Pending".

What's more, as Juvanis said, this is the standard naming convention for variables in Java.

Upvotes: 11

Related Questions