I am coding a method that returns whether a given character is valid, which looks like this: -
private static boolean isValid(char c) {
return c == '.' || c == ',' || c == '+' || c == '/' || c == ';' || c == ':';
}
Check style flagged this up as the boolean complexity is too great (5 when it should be no more than 3). My development manager has flagged up a few alternative implementations which I will post as answers. Personally, I think my code is readable enough and would prefer to turn off check style for this method.
What do you think?