Skip to content

Commit

Permalink
allow changing the merging of problems via cli
Browse files Browse the repository at this point in the history
  • Loading branch information
Luro02 committed Aug 31, 2023
1 parent cb15dd6 commit 75508ab
Showing 1 changed file with 9 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
import de.firemage.autograder.core.compiler.JavaVersion;
import de.firemage.autograder.core.errorprone.TempLocation;
import de.firemage.autograder.core.file.UploadedFile;
import de.firemage.autograder.core.integrated.SpoonUtil;
import de.firemage.autograder.span.Formatter;
import de.firemage.autograder.span.Highlight;
import de.firemage.autograder.span.Position;
Expand All @@ -29,7 +28,6 @@
import picocli.CommandLine.Parameters;
import picocli.CommandLine.Spec;

import java.io.Console;
import java.io.File;
import java.io.FileDescriptor;
import java.io.FileOutputStream;
Expand Down Expand Up @@ -87,6 +85,9 @@ public class Application implements Callable<Integer> {
@Option(names = {"-p", "--output-pretty"}, description = "Pretty print the output", defaultValue = "false")
private boolean isPrettyOutput;

@Option(names = { "--max-problems" }, description = "The maximum number of problems to report per check", defaultValue = "10")
private int maxProblemsPerCheck;

@Spec
private CommandSpec spec;

Expand Down Expand Up @@ -160,7 +161,11 @@ private void execute(
highlightFromCodePosition(position, linter.translateMessage(problem.getExplanation()))
);

String result = "[%s]: Found problem in '%s'%n".formatted(problem.getProblemType(), position.toString());
String result = "[%s]: %s - Found problem in '%s'%n".formatted(
problem.getProblemType(),
problem.getCheck().getClass().getSimpleName(),
position.toString()
);
result += formatter.render(sourceText);

return result;
Expand Down Expand Up @@ -229,7 +234,7 @@ public Integer call() {
.threads(0)
.tempLocation(this.tempLocation)
.enableDynamicAnalysis(isDynamicAnalysisEnabled)
.maxProblemsPerCheck(10)
.maxProblemsPerCheck(this.maxProblemsPerCheck)
.build();

Consumer<LinterStatus> statusConsumer = status ->
Expand Down

0 comments on commit 75508ab

Please sign in to comment.