Feuermagier / autograder

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

Add utility methods for evaluating how long a suggestion can be based on the line limit/where it is located #569

Open Luro02 opened 1 month ago

Luro02 commented 1 month ago

Description

There are some suggestions that are currently limited by some arbitrary number to prevent too short or too long things from being suggested.

For example one might introduce an "unnecessary" variable for a very long line like this:

var x = /* very large
           maybe even multiline
           expression */;
System.out.println(x);

Here it wouldn't be sensible to suggest the variable as unnecessary, because it does serve a purpose.

There are other lints who would benefit from this too. The LOOP_COULD_BE_FOR is another one, it doesn't make sense to have a for loop that must be split into multiple lines to fit into some line limit:

for (/* ... */;
     /* ... */;
     /* ... */) {
    // ...
}

For that a utility method would be nice to have. Depending on the nesting, the line limit will be different, so it makes sense to have a helper method doing this correctly.