Feuermagier / autograder

Automatic grading of student's Java code
MIT License
13 stars 7 forks source link

Suggest replacing `System.arraycopy` with `Arrays.copyOf` when applicable #513

Open Luro02 opened 2 months ago

Luro02 commented 2 months ago

What it does

This is supposed to be a lint that never deducts points. In some cases Arrays.copyOf or similar helper methods are easier to read than the code written with arraycopy.

For example getter/setter.

Important: The lint should only apply, when there is a java.util import.

Lint Name

No response

Category

api

Example

int[] result = new int[array.length];
System.arraycopy(array, 0, array.length, result, 0, result.length);
return result;

Could be written as:

return Arrays.copyOf(array);