Open Luro02 opened 5 months ago
This is an extension of #493, but for any code on the right side of a case.
If one has a switch over an enum and more than x lines of code, the lint should suggest refactoring the code, so that those are methods in the enum.
No response
switch (args[1]) { case MemoryInitMode.STOP_NAME - > { if (args.length != 1 + REQUIRED_ARGUMENT_COUNT) { return new Result(ResultType.FAILURE, WRONG_ARGUMENT_NUMBER.formatted(1)); } builder.setInitMode(MemoryInitMode.STOP); } case MemoryInitMode.RANDOM_NAME - > { if (args.length != 1 + REQUIRED_ARGUMENT_COUNT + OPTIONAL_ARGUMENT_COUNT) { return new Result(ResultType.FAILURE, NO_SEED_GIVEN); } long seed; try { seed = Long.parseLong(args[SEED_POSITION]); } catch (NumberFormatException e) { return new Result(ResultType.FAILURE, SEED_IS_NO_INTEGER); } if (seed > MAXIMUM_SEED_SIZE || seed < MINIMUM_SEED_SIZE) { return new Result(ResultType.FAILURE, SEED_RANGE); } builder.setInitMode(MemoryInitMode.RANDOM);builder.setInitModeSeed(seed); } default - > { return new Result(ResultType.FAILURE, NOT_A_MEMORY_INIT_MODE.formatted(args[1])); } }
Could be written as:
<code>
What it does
This is an extension of #493, but for any code on the right side of a case.
If one has a switch over an enum and more than x lines of code, the lint should suggest refactoring the code, so that those are methods in the enum.
Lint Name
No response
Category
No response
Example
Could be written as: