Technically, yes there is nothing wrong with your code.
The code shows that the color code for each enum type is based on the constructor (like red is 42). But, squid rule dictates that this could be "confusing" when someone is trying to debug the code (particularly, a big piece of code).
This is taken from the squid rule documentation.
Using magic numbers may seem obvious and straightforward when you're writing a piece of code, but they are much less obvious and straightforward at debugging time.
That is why magic numbers must be demystified by first being assigned to clearly named constants before being used.
-1, 0 and 1 are not considered magic numbers
So, in your code, you may want to do something like this.
public enum Color{
public final int RED_CODE = 42;
RED(RED_CODE);
public final int code;
Color(int colorCode){
this.code=colorCode;
}
}
or might as well disable the rule :D