No magic number check in definition of enumeration items

No magic number check in definition of enumeration items

This post has NOT been accepted by the mailing list yet.

It seems the "Magic Numbers" check will be reworked to excluded the number "2" as magic number. Here I have an additional request, namely the use of "magic numbers" in the definition of enums. I consider enumerations also "constants", so the use of any number should be allowed here. e.g.

enum CDataType {

uint8(1), // others left out ....
double(8);

private int byteSize;

private CDataType(final int bSize){
this.byteSize = bSize;
}

}

Here the use of the "magic number" 8 is fine, as it is used to define the properties of a "constant" enumeration item. Also it is not possible to extract the "8" into a constant inside the enumeration, so any use of symbolic constants here would lead to highly more unreadable code.

We have used NOSONAR tags at these places in our code to silence the warning but it would be much better if the "Magic number" rule would not consider this a violation.