-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* remove tests cmd & linter parameters since we no longer have dynamic analysis * new config format * validate excluded classes names
- Loading branch information
1 parent
04ce087
commit 1b1f3cd
Showing
10 changed files
with
282 additions
and
253 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
23 changes: 23 additions & 0 deletions
23
autograder-core/src/main/java/de/firemage/autograder/core/ArtemisUtil.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
package de.firemage.autograder.core; | ||
|
||
import java.io.IOException; | ||
import java.nio.file.Files; | ||
import java.nio.file.Path; | ||
import java.util.stream.Stream; | ||
|
||
public class ArtemisUtil { | ||
private ArtemisUtil() { | ||
|
||
} | ||
|
||
public static Path resolveCodePathEclipseGradingTool(Path submissionRoot) throws IOException { | ||
try (Stream<Path> files = Files.list(submissionRoot)) { | ||
return files | ||
.filter(child -> !child.endsWith(".metadata")) | ||
.findAny() | ||
.orElseThrow(() -> new IllegalStateException("No student code found")) | ||
.resolve("assignment") | ||
.resolve("src"); | ||
} | ||
} | ||
} |
39 changes: 39 additions & 0 deletions
39
autograder-core/src/main/java/de/firemage/autograder/core/CheckConfiguration.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
package de.firemage.autograder.core; | ||
|
||
import com.fasterxml.jackson.databind.ObjectMapper; | ||
import com.fasterxml.jackson.dataformat.yaml.YAMLFactory; | ||
|
||
import java.io.IOException; | ||
import java.nio.file.Files; | ||
import java.nio.file.Path; | ||
import java.util.List; | ||
|
||
public record CheckConfiguration(List<ProblemType> problemsToReport, List<String> excludedClasses) { | ||
public static CheckConfiguration empty() { | ||
return new CheckConfiguration(List.of(), List.of()); | ||
} | ||
|
||
public static CheckConfiguration fromConfigFile(Path configFile) throws IOException, LinterConfigurationException { | ||
return CheckConfiguration.fromConfigString(Files.readString(configFile)); | ||
} | ||
|
||
public static CheckConfiguration fromConfigString(String configString) throws IOException, LinterConfigurationException { | ||
var config = new ObjectMapper(new YAMLFactory()).readValue(configString, CheckConfiguration.class); | ||
config.validate(); | ||
return config; | ||
} | ||
|
||
public static CheckConfiguration fromProblemTypes(List<ProblemType> problemsToReport) { | ||
return new CheckConfiguration(problemsToReport, List.of()); | ||
} | ||
|
||
private void validate() throws LinterConfigurationException { | ||
if (this.excludedClasses != null) { | ||
for (String excludedClass : this.excludedClasses) { | ||
if (excludedClass.contains("/") || excludedClass.contains(".")) { | ||
throw new LinterConfigurationException("Invalid excluded class name '%s'. Please check your configuration.".formatted(excludedClass)); | ||
} | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
15 changes: 15 additions & 0 deletions
15
autograder-core/src/main/java/de/firemage/autograder/core/LinterConfigurationException.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
package de.firemage.autograder.core; | ||
|
||
public class LinterConfigurationException extends LinterException { | ||
public LinterConfigurationException(String message) { | ||
super(message); | ||
} | ||
|
||
public LinterConfigurationException(String message, Throwable cause) { | ||
super(message, cause); | ||
} | ||
|
||
public LinterConfigurationException(Throwable cause) { | ||
super(cause); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.