You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
which is unnecessary, because the constant values on the right could be attributes.
The same is for the inverse where the constant is on the left and the enum on the right.
Note: Those cases should be ignored by the ClosedSetShouldBeEnum check.
Alternatively one could suggest a constant map in the form Map<Enum, Constant> or Map<Constant, Enum>.
Lint Name
CONSTANT_SHOULD_BE_ENUM_ATTRIBUTE
Category
oop
Example
For example see above.
private static final int MOV_R_CASE = 1;
private static final int MOV_I_CASE = 2;
private static final int ADD_CASE = 3;
private static final int ADD_R_CASE = 4;
private static final int JMP_CASE = 5;
private static final int JMZ_CASE = 6;
private static final int CMP_CASE = 7;
private static final int SWAP_CASE = 8;
private static final int TOTAL_COMMANDS = 9;
[...]
return switch (pId) {
case MOV_R_CASE -> AiCommandType.MOV_R;
case MOV_I_CASE -> AiCommandType.MOV_I;
case ADD_CASE -> AiCommandType.ADD;
case ADD_R_CASE -> AiCommandType.ADD_R;
case JMP_CASE -> AiCommandType.JMP;
case JMZ_CASE -> AiCommandType.JMZ;
case CMP_CASE -> AiCommandType.CMP;
case SWAP_CASE -> AiCommandType.SWAP;
default -> AiCommandType.STOP;
};
The text was updated successfully, but these errors were encountered:
What it does
In Java, one can not only have a simple enumeration like
but also have attributes:
Sometimes this is not used, like here:
which is unnecessary, because the constant values on the right could be attributes.
The same is for the inverse where the constant is on the left and the enum on the right.
Note: Those cases should be ignored by the
ClosedSetShouldBeEnum
check.Alternatively one could suggest a constant map in the form
Map<Enum, Constant>
orMap<Constant, Enum>
.Lint Name
CONSTANT_SHOULD_BE_ENUM_ATTRIBUTE
Category
oop
Example
For example see above.
The text was updated successfully, but these errors were encountered: