Given this kind of code:
public static final int DEFAULT_MASK = Mask.BASE
| Mask.SECTOR
| Mask.GROUP
| Mask.INDUSTRY
| Mask.NAME
| Mask.COUNTRY;
Sonar raises a warning:
Boolean expression complexity is 5 (max allowed is 3).
What would be a good way to deal with this?
I suppose the warning might go away if I rewrite like this:
public static final int DEFAULT_MASK;
static {
int tmp = Mask.BASE;
tmp |= Mask.SECTOR;
tmp |= Mask.GROUP;
tmp |= Mask.INDUSTRY;
tmp |= Mask.NAME;
tmp |= Mask.COUNTRY;
DEFAULT_MASK = tmp;
}
... but this smells (too many mutations, ugly).
UPDATE
In addition to the default mask above, I have a few other masks as well, using different sets of bits, for different purposes. Every bitmask with more than 3 bits would raise a Sonar violation.