diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index f82555f0..595cc613 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -58,4 +58,4 @@ jobs: if: startsWith(github.ref, 'refs/tags/') with: body: 'Minor Release (mostly for the automatic download of the jar file)' - files: autograder-cmd/target/autograder-cmd.jar \ No newline at end of file + files: autograder-cmd/target/autograder-cmd.jar diff --git a/autograder-api/pom.xml b/autograder-api/pom.xml new file mode 100644 index 00000000..1df21afe --- /dev/null +++ b/autograder-api/pom.xml @@ -0,0 +1,42 @@ + + + + + de.firemage.autograder + autograder-parent + 0.5.41 + + 4.0.0 + + autograder-api + autograder-api + Frontend API for the autograder + https://github.com/Feuermagier/autograder/autograder-api + + + + net.xyzsd.fluent + fluent-base + ${fluent.version} + + + + org.reflections + reflections + + + + + com.fasterxml.jackson.dataformat + jackson-dataformat-yaml + ${jackson.version} + + + com.fasterxml.jackson.core + jackson-databind + ${jackson.version} + + + diff --git a/autograder-api/src/main/java/de/firemage/autograder/api/AbstractCodePosition.java b/autograder-api/src/main/java/de/firemage/autograder/api/AbstractCodePosition.java new file mode 100644 index 00000000..147eb21d --- /dev/null +++ b/autograder-api/src/main/java/de/firemage/autograder/api/AbstractCodePosition.java @@ -0,0 +1,15 @@ +package de.firemage.autograder.api; + +import java.nio.file.Path; + +public interface AbstractCodePosition { + Path path(); + int startLine(); + + int endLine(); + + int startColumn(); + + int endColumn(); + String readSourceFile(); +} diff --git a/autograder-api/src/main/java/de/firemage/autograder/api/AbstractLinter.java b/autograder-api/src/main/java/de/firemage/autograder/api/AbstractLinter.java new file mode 100644 index 00000000..8ad28f41 --- /dev/null +++ b/autograder-api/src/main/java/de/firemage/autograder/api/AbstractLinter.java @@ -0,0 +1,68 @@ +package de.firemage.autograder.api; + +import java.io.IOException; +import java.nio.file.Path; +import java.util.List; +import java.util.Locale; +import java.util.function.Consumer; + +public interface AbstractLinter { + List checkFile(Path file, JavaVersion version, CheckConfiguration checkConfiguration, Consumer statusConsumer) throws LinterException, IOException; + String translateMessage(Translatable translatable); + + static Builder builder(Locale locale) { + return new Builder(locale); + } + + class Builder { + private final Locale locale; + private AbstractTempLocation tempLocation; + private int threads; + private ClassLoader classLoader; + private int maxProblemsPerCheck = -1; + + private Builder(Locale locale) { + this.locale = locale; + } + + public Builder tempLocation(AbstractTempLocation tempLocation) { + this.tempLocation = tempLocation; + return this; + } + + public AbstractTempLocation getTempLocation() { + return tempLocation; + } + + public Builder threads(int threads) { + this.threads = threads; + return this; + } + + public int getThreads() { + return threads; + } + + public Builder maxProblemsPerCheck(int maxProblemsPerCheck) { + this.maxProblemsPerCheck = maxProblemsPerCheck; + return this; + } + + public int getMaxProblemsPerCheck() { + return maxProblemsPerCheck; + } + + public Builder classLoader(ClassLoader classLoader) { + this.classLoader = classLoader; + return this; + } + + public ClassLoader getClassLoader() { + return classLoader; + } + + public Locale getLocale() { + return locale; + } + } +} diff --git a/autograder-api/src/main/java/de/firemage/autograder/api/AbstractProblem.java b/autograder-api/src/main/java/de/firemage/autograder/api/AbstractProblem.java new file mode 100644 index 00000000..adf4e022 --- /dev/null +++ b/autograder-api/src/main/java/de/firemage/autograder/api/AbstractProblem.java @@ -0,0 +1,10 @@ +package de.firemage.autograder.api; + +public interface AbstractProblem { + String getCheckName(); + Translatable getLinterName(); + Translatable getExplanation(); + String getDisplayLocation(); + AbstractCodePosition getPosition(); + String getType(); +} diff --git a/autograder-api/src/main/java/de/firemage/autograder/api/AbstractProblemType.java b/autograder-api/src/main/java/de/firemage/autograder/api/AbstractProblemType.java new file mode 100644 index 00000000..787b2289 --- /dev/null +++ b/autograder-api/src/main/java/de/firemage/autograder/api/AbstractProblemType.java @@ -0,0 +1,4 @@ +package de.firemage.autograder.api; + +public interface AbstractProblemType { +} diff --git a/autograder-api/src/main/java/de/firemage/autograder/api/AbstractTempLocation.java b/autograder-api/src/main/java/de/firemage/autograder/api/AbstractTempLocation.java new file mode 100644 index 00000000..1e37aaa6 --- /dev/null +++ b/autograder-api/src/main/java/de/firemage/autograder/api/AbstractTempLocation.java @@ -0,0 +1,12 @@ +package de.firemage.autograder.api; + +import java.io.Closeable; +import java.io.IOException; +import java.io.Serializable; +import java.nio.file.Path; + +public interface AbstractTempLocation extends Closeable, Serializable { + AbstractTempLocation createTempDirectory(String prefix) throws IOException; + Path createTempFile(String name) throws IOException; + Path toPath(); +} diff --git a/autograder-core/src/main/java/de/firemage/autograder/core/ArtemisUtil.java b/autograder-api/src/main/java/de/firemage/autograder/api/ArtemisUtil.java similarity index 94% rename from autograder-core/src/main/java/de/firemage/autograder/core/ArtemisUtil.java rename to autograder-api/src/main/java/de/firemage/autograder/api/ArtemisUtil.java index 80bdf5ef..81012609 100644 --- a/autograder-core/src/main/java/de/firemage/autograder/core/ArtemisUtil.java +++ b/autograder-api/src/main/java/de/firemage/autograder/api/ArtemisUtil.java @@ -1,4 +1,4 @@ -package de.firemage.autograder.core; +package de.firemage.autograder.api; import java.io.IOException; import java.nio.file.Files; diff --git a/autograder-core/src/main/java/de/firemage/autograder/core/CheckConfiguration.java b/autograder-api/src/main/java/de/firemage/autograder/api/CheckConfiguration.java similarity index 62% rename from autograder-core/src/main/java/de/firemage/autograder/core/CheckConfiguration.java rename to autograder-api/src/main/java/de/firemage/autograder/api/CheckConfiguration.java index c0e99159..cc208096 100644 --- a/autograder-core/src/main/java/de/firemage/autograder/core/CheckConfiguration.java +++ b/autograder-api/src/main/java/de/firemage/autograder/api/CheckConfiguration.java @@ -1,14 +1,16 @@ -package de.firemage.autograder.core; +package de.firemage.autograder.api; import com.fasterxml.jackson.databind.ObjectMapper; +import com.fasterxml.jackson.databind.module.SimpleModule; import com.fasterxml.jackson.dataformat.yaml.YAMLFactory; +import de.firemage.autograder.api.loader.ImplementationBinder; import java.io.IOException; import java.nio.file.Files; import java.nio.file.Path; import java.util.List; -public record CheckConfiguration(List problemsToReport, List excludedClasses) { +public record CheckConfiguration(List problemsToReport, List excludedClasses) { public static CheckConfiguration empty() { return new CheckConfiguration(List.of(), List.of()); } @@ -21,12 +23,19 @@ public static CheckConfiguration fromConfigString(String configString) throws IO if (!configString.contains("problemsToReport") && configString.startsWith("[")) { configString = "problemsToReport: " + configString; } - var config = new ObjectMapper(new YAMLFactory()).readValue(configString, CheckConfiguration.class); + + // Tell Jackson how to instantiate AbstractProblemType + var coreModule = new SimpleModule("autograder-core"); + coreModule.addAbstractTypeMapping(AbstractProblemType.class, new ImplementationBinder<>(AbstractProblemType.class).findImplementation()); + + var mapper = new ObjectMapper(new YAMLFactory()); + mapper.registerModule(coreModule); + var config = mapper.readValue(configString, CheckConfiguration.class); config.validate(); return config; } - public static CheckConfiguration fromProblemTypes(List problemsToReport) { + public static CheckConfiguration fromProblemTypes(List problemsToReport) { return new CheckConfiguration(problemsToReport, List.of()); } diff --git a/autograder-core/src/main/java/de/firemage/autograder/core/HasFalsePositives.java b/autograder-api/src/main/java/de/firemage/autograder/api/HasFalsePositives.java similarity index 90% rename from autograder-core/src/main/java/de/firemage/autograder/core/HasFalsePositives.java rename to autograder-api/src/main/java/de/firemage/autograder/api/HasFalsePositives.java index 7db2b8c6..a8c1ee75 100644 --- a/autograder-core/src/main/java/de/firemage/autograder/core/HasFalsePositives.java +++ b/autograder-api/src/main/java/de/firemage/autograder/api/HasFalsePositives.java @@ -1,4 +1,4 @@ -package de.firemage.autograder.core; +package de.firemage.autograder.api; import java.lang.annotation.ElementType; import java.lang.annotation.Retention; diff --git a/autograder-core/src/main/java/de/firemage/autograder/core/compiler/JavaVersion.java b/autograder-api/src/main/java/de/firemage/autograder/api/JavaVersion.java similarity index 96% rename from autograder-core/src/main/java/de/firemage/autograder/core/compiler/JavaVersion.java rename to autograder-api/src/main/java/de/firemage/autograder/api/JavaVersion.java index b487e63f..7fb73529 100644 --- a/autograder-core/src/main/java/de/firemage/autograder/core/compiler/JavaVersion.java +++ b/autograder-api/src/main/java/de/firemage/autograder/api/JavaVersion.java @@ -1,4 +1,4 @@ -package de.firemage.autograder.core.compiler; +package de.firemage.autograder.api; import java.util.Arrays; import java.util.Comparator; diff --git a/autograder-core/src/main/java/de/firemage/autograder/core/LinterConfigurationException.java b/autograder-api/src/main/java/de/firemage/autograder/api/LinterConfigurationException.java similarity index 90% rename from autograder-core/src/main/java/de/firemage/autograder/core/LinterConfigurationException.java rename to autograder-api/src/main/java/de/firemage/autograder/api/LinterConfigurationException.java index b85e8b4b..8da6654e 100644 --- a/autograder-core/src/main/java/de/firemage/autograder/core/LinterConfigurationException.java +++ b/autograder-api/src/main/java/de/firemage/autograder/api/LinterConfigurationException.java @@ -1,4 +1,4 @@ -package de.firemage.autograder.core; +package de.firemage.autograder.api; public class LinterConfigurationException extends LinterException { public LinterConfigurationException(String message) { diff --git a/autograder-core/src/main/java/de/firemage/autograder/core/LinterException.java b/autograder-api/src/main/java/de/firemage/autograder/api/LinterException.java similarity index 90% rename from autograder-core/src/main/java/de/firemage/autograder/core/LinterException.java rename to autograder-api/src/main/java/de/firemage/autograder/api/LinterException.java index 2ae2dc19..7e5df740 100644 --- a/autograder-core/src/main/java/de/firemage/autograder/core/LinterException.java +++ b/autograder-api/src/main/java/de/firemage/autograder/api/LinterException.java @@ -1,4 +1,4 @@ -package de.firemage.autograder.core; +package de.firemage.autograder.api; public class LinterException extends Exception { public LinterException() { diff --git a/autograder-api/src/main/java/de/firemage/autograder/api/PathLike.java b/autograder-api/src/main/java/de/firemage/autograder/api/PathLike.java new file mode 100644 index 00000000..8517d413 --- /dev/null +++ b/autograder-api/src/main/java/de/firemage/autograder/api/PathLike.java @@ -0,0 +1,7 @@ +package de.firemage.autograder.api; + +import java.nio.file.Path; + +public interface PathLike { + Path toPath(); +} diff --git a/autograder-core/src/main/java/de/firemage/autograder/core/Translatable.java b/autograder-api/src/main/java/de/firemage/autograder/api/Translatable.java similarity index 78% rename from autograder-core/src/main/java/de/firemage/autograder/core/Translatable.java rename to autograder-api/src/main/java/de/firemage/autograder/api/Translatable.java index e17ced4b..24c306f0 100644 --- a/autograder-core/src/main/java/de/firemage/autograder/core/Translatable.java +++ b/autograder-api/src/main/java/de/firemage/autograder/api/Translatable.java @@ -1,4 +1,4 @@ -package de.firemage.autograder.core; +package de.firemage.autograder.api; import fluent.bundle.FluentBundle; diff --git a/autograder-api/src/main/java/de/firemage/autograder/api/loader/AutograderLoader.java b/autograder-api/src/main/java/de/firemage/autograder/api/loader/AutograderLoader.java new file mode 100644 index 00000000..40c135ec --- /dev/null +++ b/autograder-api/src/main/java/de/firemage/autograder/api/loader/AutograderLoader.java @@ -0,0 +1,116 @@ +package de.firemage.autograder.api.loader; + +import de.firemage.autograder.api.AbstractLinter; +import de.firemage.autograder.api.AbstractProblemType; +import de.firemage.autograder.api.AbstractTempLocation; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import java.io.FileOutputStream; +import java.io.IOException; +import java.net.URL; +import java.net.URLClassLoader; +import java.net.URLConnection; +import java.nio.channels.Channels; +import java.nio.channels.ReadableByteChannel; +import java.nio.file.Path; +import java.nio.file.Files; + +public class AutograderLoader { + private static final String AUTOGRADER_DOWNLOAD_URL = "https://github.com/Feuermagier/autograder/releases/latest/download/autograder-cmd.jar"; + private static final String AUTOGRADER_RELEASE_PATH = "https://github.com/Feuermagier/autograder/releases/latest"; + + private static final Logger LOG = LoggerFactory.getLogger(AutograderLoader.class); + + private static URLClassLoader autograderClassLoader = null; + private static String currentTag = null; + private static Path downloadedAutograderPath = null; + + public static void loadFromFile(Path autograderPath) throws IOException { + loadAutograderIntoProcess(autograderPath); + } + + public static void loadFromGithubWithExtraChecks() throws IOException { + String tag = getAutograderVersionTag(); + if (downloadedAutograderPath == null || !downloadedAutograderPath.getFileName().startsWith(tag)) { + downloadAutograderRelease(tag); + } + currentTag = tag; + loadAutograderIntoProcess(downloadedAutograderPath); + } + + public static boolean isCurrentVersionLoaded() throws IOException { + if (downloadedAutograderPath == null) { + return true; + } + + return getAutograderVersionTag().equals(currentTag); + } + + public static boolean isAutograderLoaded() { + return autograderClassLoader != null; + } + + public static AbstractLinter instantiateLinter(AbstractLinter.Builder builder) { + return new ImplementationBinder<>(AbstractLinter.class) + .param(AbstractLinter.Builder.class, builder) + .classLoader(autograderClassLoader) + .instantiate(); + } + + public static AbstractTempLocation instantiateTempLocation(Path path) { + return new ImplementationBinder<>(AbstractTempLocation.class) + .param(Path.class, path) + .classLoader(autograderClassLoader) + .instantiate(); + } + + public static AbstractTempLocation instantiateTempLocation() { + return new ImplementationBinder<>(AbstractTempLocation.class) + .classLoader(autograderClassLoader) + .instantiate(); + } + + public static AbstractProblemType convertProblemType(String problemType) { + return new ImplementationBinder<>(AbstractProblemType.class) + .param(String.class, problemType) + .classLoader(autograderClassLoader) + .callStatic("fromString", AbstractProblemType.class); + } + + private static String getAutograderVersionTag() throws IOException { + URLConnection connection = new URL(AUTOGRADER_RELEASE_PATH).openConnection(); + connection.connect(); + // Open stream to force redirect to the latest release + try (var inputStream = connection.getInputStream()) { + String[] components = connection.getURL().getFile().split("/"); + return components[components.length - 1]; + } + } + + private static void downloadAutograderRelease(String tag) throws IOException { + Path targetPath = Files.createTempFile(tag + "_autograder_jar", ".jar"); + LOG.info("Downloading autograder JAR with version/tag {} to {}", tag, targetPath.toAbsolutePath()); + Files.deleteIfExists(targetPath); + Files.createFile(targetPath); + URL url = new URL(AUTOGRADER_DOWNLOAD_URL); + ReadableByteChannel channel = Channels.newChannel(url.openStream()); + try (var outStream = new FileOutputStream(targetPath.toFile())) { + outStream.getChannel().transferFrom(channel, 0, Long.MAX_VALUE); + } + downloadedAutograderPath = targetPath; + } + + private static void loadAutograderIntoProcess(Path jar) throws IOException { + if (autograderClassLoader != null) { + throw new IllegalStateException("Autograder already loaded. Restart the process to load a new version."); + } + + if (!Files.exists(jar)) { + throw new IOException("Autograder JAR not found at " + jar.toAbsolutePath()); + } + + LOG.info("Loading autograder JAR from {}", jar.toAbsolutePath()); + autograderClassLoader = new URLClassLoader(new URL[]{jar.toUri().toURL()}, AutograderLoader.class.getClassLoader()); + } +} diff --git a/autograder-api/src/main/java/de/firemage/autograder/api/loader/ImplementationBinder.java b/autograder-api/src/main/java/de/firemage/autograder/api/loader/ImplementationBinder.java new file mode 100644 index 00000000..39c0adff --- /dev/null +++ b/autograder-api/src/main/java/de/firemage/autograder/api/loader/ImplementationBinder.java @@ -0,0 +1,96 @@ +package de.firemage.autograder.api.loader; + +import org.reflections.Reflections; +import org.reflections.util.ClasspathHelper; +import org.reflections.util.ConfigurationBuilder; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import static org.reflections.scanners.Scanners.SubTypes; + +public class ImplementationBinder { + private static final Logger LOG = LoggerFactory.getLogger(ImplementationBinder.class); + + private static final Map> reflectionCache = new HashMap<>(); + + private final Class superType; + private final List> parameterTypes = new ArrayList<>(); + private final List arguments = new ArrayList<>(); + private ClassLoader classLoader; + + public ImplementationBinder(Class superType) { + this.superType = superType; + } + + public

ImplementationBinder param(Class

type, P value) { + parameterTypes.add(type); + arguments.add(value); + return this; + } + + public ImplementationBinder classLoader(ClassLoader classLoader) { + this.classLoader = classLoader; + return this; + } + + public T instantiate() { + var implementation = findImplementation(); + + try { + return implementation.getConstructor(parameterTypes.toArray(new Class[0])).newInstance(arguments.toArray()); + } catch (ReflectiveOperationException e) { + throw new IllegalStateException("Failed to instantiate " + implementation.getName() + " with a constructor with parameters " + parameterTypes, e); + } + } + + public R callStatic(String methodName, Class returnType) { + var implementation = findImplementation(); + + try { + var method = implementation.getMethod(methodName, parameterTypes.toArray(new Class[0])); + return returnType.cast(method.invoke(null, arguments.toArray())); + } catch (ReflectiveOperationException e) { + throw new IllegalStateException("Failed to call static method " + methodName + " on " + implementation.getName(), e); + } + } + + public Class findImplementation() { + if (this.classLoader == null) { + this.classLoader = this.getClass().getClassLoader(); + } + + String superTypeName = superType.getName(); + if (!reflectionCache.containsKey(superTypeName)) { + var config = new ConfigurationBuilder() + .setUrls(ClasspathHelper.forPackage("de.firemage.autograder", this.classLoader)) + .forPackage("de.firemage.autograder") + .setClassLoaders(new ClassLoader[]{this.classLoader}) + .setExpandSuperTypes(false) + .setScanners(SubTypes); + var implementations = new Reflections(config).get(SubTypes.of(this.superType).asClass(this.classLoader)); + + if (implementations.isEmpty()) { + throw new IllegalStateException("No implementation found for " + superTypeName + ". Check your classpath."); + } + if (implementations.size() > 1) { + throw new IllegalStateException("More than one implementation found for " + superTypeName + ". Check your classpath."); + } + + LOG.info("Found implementation {} for {}", implementations.iterator().next().getName(), superTypeName); + reflectionCache.put(superTypeName, implementations.iterator().next()); + } + + @SuppressWarnings("unchecked") + var implementation = (Class) reflectionCache.get(superType.getName()); + return implementation; + } + + public static void invalidateCache() { + reflectionCache.clear(); + } +} diff --git a/autograder-api/src/test/java/de/firemage/autograder/api/loader/AutograderLoaderTest.java b/autograder-api/src/test/java/de/firemage/autograder/api/loader/AutograderLoaderTest.java new file mode 100644 index 00000000..f7be6081 --- /dev/null +++ b/autograder-api/src/test/java/de/firemage/autograder/api/loader/AutograderLoaderTest.java @@ -0,0 +1,36 @@ +package de.firemage.autograder.api.loader; + +import de.firemage.autograder.api.AbstractLinter; +import de.firemage.autograder.api.AbstractTempLocation; +import org.junit.jupiter.api.Disabled; +import org.junit.jupiter.api.Test; + +import java.io.IOException; +import java.nio.file.Path; +import java.util.Locale; + +import static org.junit.jupiter.api.Assertions.*; + +@Disabled("This test is disabled because it requires the autograder-cmd.jar to be present in the target directory, which is not the case in the CI pipeline.") +class AutograderLoaderTest { + @Test + void testLoadFromFile() throws IOException { + Path path = Path.of("../autograder-cmd/target/autograder-cmd.jar"); + AutograderLoader.loadFromFile(path); + this.assertClassesPresent(); + } + + private void assertClassesPresent() throws IOException { + assertTrue(AutograderLoader.isAutograderLoaded()); + + AbstractTempLocation randomTempLocation = AutograderLoader.instantiateTempLocation(); + randomTempLocation.close(); + + AbstractTempLocation fixedTempLocation = AutograderLoader.instantiateTempLocation(Path.of(".autograder-tmp")); + fixedTempLocation.close(); + + AutograderLoader.instantiateLinter(AbstractLinter.builder(Locale.US)); + + AutograderLoader.convertProblemType("ASSERT"); + } +} diff --git a/autograder-cmd/pom.xml b/autograder-cmd/pom.xml index f9e7f163..9c10efdf 100644 --- a/autograder-cmd/pom.xml +++ b/autograder-cmd/pom.xml @@ -22,19 +22,22 @@ de.firemage.autograder - autograder-core + autograder-api - de.firemage.autograder - autograder-extra + autograder-span - de.firemage.autograder - autograder-span + autograder-core + + + de.firemage.autograder + autograder-extra + info.picocli diff --git a/autograder-cmd/src/main/java/de/firemage/autograder/cmd/Application.java b/autograder-cmd/src/main/java/de/firemage/autograder/cmd/Application.java index 612393e7..f6d4d12c 100644 --- a/autograder-cmd/src/main/java/de/firemage/autograder/cmd/Application.java +++ b/autograder-cmd/src/main/java/de/firemage/autograder/cmd/Application.java @@ -2,19 +2,18 @@ import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.databind.ObjectMapper; +import de.firemage.autograder.api.ArtemisUtil; +import de.firemage.autograder.api.CheckConfiguration; +import de.firemage.autograder.api.AbstractCodePosition; +import de.firemage.autograder.api.JavaVersion; +import de.firemage.autograder.api.AbstractLinter; +import de.firemage.autograder.api.LinterConfigurationException; +import de.firemage.autograder.api.LinterException; +import de.firemage.autograder.api.AbstractProblem; +import de.firemage.autograder.api.AbstractTempLocation; +import de.firemage.autograder.api.Translatable; +import de.firemage.autograder.api.loader.AutograderLoader; import de.firemage.autograder.cmd.output.Annotation; -import de.firemage.autograder.core.ArtemisUtil; -import de.firemage.autograder.core.CheckConfiguration; -import de.firemage.autograder.core.CodePosition; -import de.firemage.autograder.core.Linter; -import de.firemage.autograder.core.LinterConfigurationException; -import de.firemage.autograder.core.LinterException; -import de.firemage.autograder.core.LinterStatus; -import de.firemage.autograder.core.Problem; -import de.firemage.autograder.core.compiler.CompilationFailureException; -import de.firemage.autograder.core.compiler.JavaVersion; -import de.firemage.autograder.core.file.TempLocation; -import de.firemage.autograder.core.file.UploadedFile; import de.firemage.autograder.span.Formatter; import de.firemage.autograder.span.Highlight; import de.firemage.autograder.span.Position; @@ -48,11 +47,8 @@ description = "Static code analysis for student java code") public class Application implements Callable { private static final int IO_EXIT_CODE = 3; - private static final int COMPILATION_EXIT_CODE = 4; private static final int MISC_EXIT_CODE = 10; - private static final int CAPTION_LENGTH = 20; - @Parameters(index = "0", description = "The check configuration.") private String checkConfig; @@ -72,7 +68,7 @@ public class Application implements Callable { // TODO: remove this @Option(names = { - "--static-only"}, description = "Only kept here so the grading tool keeps working, does nothing.") + "--static-only"}, description = "Only kept here so the grading tool keeps working, does nothing.") private boolean staticOnly; @Option(names = { @@ -82,15 +78,15 @@ public class Application implements Callable { @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") + @Option(names = {"--max-problems"}, description = "The maximum number of problems to report per check", defaultValue = "10") private int maxProblemsPerCheck; @Spec private CommandSpec spec; - private final TempLocation tempLocation; + private final AbstractTempLocation tempLocation; - public Application(TempLocation tempLocation) { + public Application(AbstractTempLocation tempLocation) { this.tempLocation = tempLocation; } @@ -107,32 +103,31 @@ public static void main(String... args) { // Useful for testing public static int runApplication(String... args) { // to automatically delete the temp location on exit - try (TempLocation tempLocation = TempLocation.of(".autograder-tmp")) { + try (var tempLocation = AutograderLoader.instantiateTempLocation(Path.of(".autograder-tmp"))) { return new CommandLine(new Application(tempLocation)).execute(args); } catch (IOException exception) { throw new IllegalArgumentException("Could not create temp location", exception); } } - private static Highlight highlightFromCodePosition(CodePosition codePosition, String label) { + private static Highlight highlightFromCodePosition(AbstractCodePosition codePosition, String label) { return new Highlight( - new Span( - new Position(codePosition.startLine() - 1, codePosition.startColumn() - 1), - new Position(codePosition.endLine() - 1, codePosition.endColumn() - 1) - ), - Optional.ofNullable(label), - Style.ERROR + new Span( + new Position(codePosition.startLine() - 1, codePosition.startColumn() - 1), + new Position(codePosition.endLine() - 1, codePosition.endColumn() - 1) + ), + Optional.ofNullable(label), + Style.ERROR ); } private void execute( - Linter linter, - CheckConfiguration checkConfiguration, - UploadedFile uploadedFile, - Consumer statusConsumer + AbstractLinter linter, + CheckConfiguration checkConfiguration, + Consumer statusConsumer ) throws LinterException, IOException { if (outputJson) { - List problems = linter.checkFile(uploadedFile, checkConfiguration, statusConsumer); + var problems = linter.checkFile(this.file, JavaVersion.fromString(this.javaVersion), checkConfiguration, statusConsumer); System.out.println(">> Problems <<"); printProblemsAsJson(problems, linter); return; @@ -142,7 +137,7 @@ private void execute( CmdUtil.beginSection("Checks"); ProgressAnimation progress = new ProgressAnimation("Checking..."); progress.start(); - List problems = linter.checkFile(uploadedFile, checkConfiguration, statusConsumer); + var problems = linter.checkFile(this.file, JavaVersion.fromString(this.javaVersion), checkConfiguration, statusConsumer); progress.finish("Completed checks"); if (problems.isEmpty()) { @@ -150,24 +145,24 @@ private void execute( } else { CmdUtil.println("Found " + problems.size() + " problem(s):"); problems.stream() - .map(problem -> { - CodePosition position = problem.getPosition(); - Text sourceText = Text.fromString(0, position.readString()); - Formatter formatter = new Formatter( - System.lineSeparator(), - highlightFromCodePosition(position, linter.translateMessage(problem.getExplanation())) - ); - - String result = "[%s]: %s - Found problem in '%s'%n".formatted( - problem.getProblemType(), - problem.getCheck().getClass().getSimpleName(), - position.toString() - ); - result += formatter.render(sourceText); - - return result; - }) - .forEach(string -> CmdUtil.println(string + System.lineSeparator())); + .map(problem -> { + AbstractCodePosition position = problem.getPosition(); + Text sourceText = Text.fromString(0, position.readSourceFile()); + Formatter formatter = new Formatter( + System.lineSeparator(), + highlightFromCodePosition(position, linter.translateMessage(problem.getExplanation())) + ); + + String result = "[%s]: %s - Found problem in '%s'%n".formatted( + problem.getType(), + problem.getCheckName(), + position.toString() + ); + result += formatter.render(sourceText); + + return result; + }) + .forEach(string -> CmdUtil.println(string + System.lineSeparator())); } CmdUtil.endSection(); @@ -177,7 +172,7 @@ private void execute( CmdUtil.beginSection("Checks"); ProgressAnimation progress = new ProgressAnimation("Checking..."); progress.start(); - List problems = linter.checkFile(uploadedFile, checkConfiguration, statusConsumer); + var problems = linter.checkFile(this.file, JavaVersion.fromString(this.javaVersion), checkConfiguration, statusConsumer); progress.finish("Completed checks"); printProblems(problems, linter); @@ -217,30 +212,21 @@ public Integer call() { return IO_EXIT_CODE; } - Linter linter = Linter.builder(Locale.GERMANY) - .threads(0) - .tempLocation(this.tempLocation) - .maxProblemsPerCheck(this.maxProblemsPerCheck) - .build(); + AbstractLinter linter = AutograderLoader.instantiateLinter(AbstractLinter.builder(Locale.GERMANY) + .threads(0) + .tempLocation(this.tempLocation) + .maxProblemsPerCheck(this.maxProblemsPerCheck)); - Consumer statusConsumer = status -> - System.out.println(linter.translateMessage(status.getMessage())); + Consumer statusConsumer = status -> + System.out.println(linter.translateMessage(status)); if (!Files.exists(file)) { CmdUtil.printlnErr("The path '%s' does not exist".formatted(file)); - return COMPILATION_EXIT_CODE; + return IO_EXIT_CODE; } - try (UploadedFile uploadedFile = UploadedFile.build( - file, - JavaVersion.fromString(this.javaVersion), - this.tempLocation, - statusConsumer, - null)) { - this.execute(linter, checkConfiguration, uploadedFile, statusConsumer); - } catch (CompilationFailureException e) { - CmdUtil.printlnErr("Compilation failed: " + e.getMessage()); - return COMPILATION_EXIT_CODE; + try { + this.execute(linter, checkConfiguration, statusConsumer); } catch (LinterException e) { e.printStackTrace(); return MISC_EXIT_CODE; @@ -252,7 +238,7 @@ public Integer call() { return 0; } - private void printProblems(List problems, Linter linter) { + private void printProblems(List problems, AbstractLinter linter) { if (problems.isEmpty()) { CmdUtil.println("No problems found - good job!"); } else { @@ -261,17 +247,17 @@ private void printProblems(List problems, Linter linter) { } } - private void printProblemsAsJson(Collection problems, Linter linter) { + private void printProblemsAsJson(Collection problems, AbstractLinter linter) { try { ObjectMapper mapper = new ObjectMapper(); String jsonOutput = mapper.writeValueAsString(problems.stream().map(problem -> { - CodePosition position = problem.getPosition(); + AbstractCodePosition position = problem.getPosition(); return new Annotation( - problem.getProblemType(), - linter.translateMessage(problem.getExplanation()), - position.file().toString().replace("\\", "/"), - position.startLine(), - position.endLine() + problem.getType(), + linter.translateMessage(problem.getExplanation()), + position.path().toString().replace("\\", "/"), + position.startLine(), + position.endLine() ); }).toList()); System.out.println(jsonOutput); @@ -280,10 +266,10 @@ private void printProblemsAsJson(Collection problems, Linter } } - private String formatProblem(Problem problem, Linter linter) { + private String formatProblem(AbstractProblem problem, AbstractLinter linter) { return String.format("%s %s (Source: %s)", problem.getDisplayLocation(), linter.translateMessage(problem.getExplanation()), - linter.translateMessage(problem.getCheck().getLinter())); + linter.translateMessage(problem.getLinterName())); } } diff --git a/autograder-cmd/src/main/java/de/firemage/autograder/cmd/output/Annotation.java b/autograder-cmd/src/main/java/de/firemage/autograder/cmd/output/Annotation.java index 5aa2ecb8..b3316ade 100644 --- a/autograder-cmd/src/main/java/de/firemage/autograder/cmd/output/Annotation.java +++ b/autograder-cmd/src/main/java/de/firemage/autograder/cmd/output/Annotation.java @@ -1,6 +1,4 @@ package de.firemage.autograder.cmd.output; -import de.firemage.autograder.core.ProblemType; - -public record Annotation(ProblemType type, String message, String file, int startLine, int endLine) { +public record Annotation(String type, String message, String file, int startLine, int endLine) { } diff --git a/autograder-core/pom.xml b/autograder-core/pom.xml index cb198e65..02e417d9 100644 --- a/autograder-core/pom.xml +++ b/autograder-core/pom.xml @@ -11,14 +11,16 @@ autograder-core autograder-core - Core checking code of the Autograder + Core checks of the autograder https://github.com/Feuermagier/autograder/autograder-core - - 0.70 - - + + + de.firemage.autograder + autograder-api + + fr.inria.gforge.spoon @@ -44,18 +46,6 @@ - - - com.fasterxml.jackson.dataformat - jackson-dataformat-yaml - ${jackson.version} - - - com.fasterxml.jackson.core - jackson-databind - ${jackson.version} - - org.slf4j jcl-over-slf4j @@ -85,7 +75,6 @@ org.reflections reflections - 0.10.2 diff --git a/autograder-core/src/main/java/de/firemage/autograder/core/CodeLinter.java b/autograder-core/src/main/java/de/firemage/autograder/core/CodeLinter.java index d8cbddf9..31fc0aa8 100644 --- a/autograder-core/src/main/java/de/firemage/autograder/core/CodeLinter.java +++ b/autograder-core/src/main/java/de/firemage/autograder/core/CodeLinter.java @@ -1,7 +1,8 @@ package de.firemage.autograder.core; +import de.firemage.autograder.api.Translatable; import de.firemage.autograder.core.check.Check; -import de.firemage.autograder.core.file.TempLocation; +import de.firemage.autograder.api.AbstractTempLocation; import de.firemage.autograder.core.file.UploadedFile; import java.io.IOException; @@ -24,9 +25,9 @@ public interface CodeLinter { */ List lint( UploadedFile submission, - TempLocation tempLocation, + AbstractTempLocation tempLocation, ClassLoader classLoader, List checks, - Consumer statusConsumer + Consumer statusConsumer ) throws IOException; } diff --git a/autograder-core/src/main/java/de/firemage/autograder/core/CodePosition.java b/autograder-core/src/main/java/de/firemage/autograder/core/CodePosition.java index e7346da9..6abb6996 100644 --- a/autograder-core/src/main/java/de/firemage/autograder/core/CodePosition.java +++ b/autograder-core/src/main/java/de/firemage/autograder/core/CodePosition.java @@ -1,5 +1,6 @@ package de.firemage.autograder.core; +import de.firemage.autograder.api.AbstractCodePosition; import de.firemage.autograder.core.file.SourceInfo; import de.firemage.autograder.core.file.SourcePath; import spoon.reflect.code.CtAbstractSwitch; @@ -11,8 +12,9 @@ import java.io.File; import java.io.IOException; +import java.nio.file.Path; -public record CodePosition(SourceInfo sourceInfo, SourcePath file, int startLine, int endLine, int startColumn, int endColumn) { +public record CodePosition(SourceInfo sourceInfo, SourcePath file, int startLine, int endLine, int startColumn, int endColumn) implements AbstractCodePosition { public static CodePosition fromSourcePosition( SourcePosition sourcePosition, CtElement ctElement, @@ -55,7 +57,14 @@ public static CodePosition fromSourcePosition( ); } - public String readString() { + + @Override + public Path path() { + return this.file.toPath(); + } + + @Override + public String readSourceFile() { try { return this.sourceInfo.getCompilationUnit(this.file).readString(); } catch (IOException exception) { diff --git a/autograder-core/src/main/java/de/firemage/autograder/core/Linter.java b/autograder-core/src/main/java/de/firemage/autograder/core/Linter.java index 2218b526..68c5a0e2 100644 --- a/autograder-core/src/main/java/de/firemage/autograder/core/Linter.java +++ b/autograder-core/src/main/java/de/firemage/autograder/core/Linter.java @@ -1,7 +1,13 @@ package de.firemage.autograder.core; +import de.firemage.autograder.api.AbstractProblemType; +import de.firemage.autograder.api.CheckConfiguration; +import de.firemage.autograder.api.AbstractLinter; +import de.firemage.autograder.api.LinterException; +import de.firemage.autograder.api.Translatable; import de.firemage.autograder.core.check.Check; import de.firemage.autograder.core.check.ExecutableCheck; +import de.firemage.autograder.api.JavaVersion; import de.firemage.autograder.core.file.TempLocation; import de.firemage.autograder.core.file.UploadedFile; import de.firemage.autograder.core.parallel.AnalysisResult; @@ -16,6 +22,7 @@ import java.io.IOException; import java.nio.charset.StandardCharsets; +import java.nio.file.Path; import java.util.ArrayList; import java.util.Collection; import java.util.IdentityHashMap; @@ -27,20 +34,21 @@ import java.util.function.Consumer; import java.util.stream.Collectors; -public final class Linter { +public final class Linter implements AbstractLinter { private final int threads; private final TempLocation tempLocation; private final FluentBundle fluentBundle; private final ClassLoader classLoader; private final int maxProblemsPerCheck; - private Linter( - Locale locale, - TempLocation tempLocation, - int threads, - ClassLoader classLoader, - int maxProblemsPerCheck + public static Linter defaultLinter(Locale locale) { + return new Linter(AbstractLinter.builder(locale)); + } + + public Linter( + AbstractLinter.Builder builder ) { + var locale = builder.getLocale(); String filename = switch (locale.getLanguage()) { case "de" -> "/strings.de.ftl"; case "en" -> "/strings.en.ftl"; @@ -55,96 +63,37 @@ private Linter( throw new IllegalStateException(e); } - this.tempLocation = tempLocation; - this.threads = threads; - this.classLoader = classLoader; - this.maxProblemsPerCheck = maxProblemsPerCheck; - } - - public static class Builder { - private final Locale locale; - private TempLocation tempLocation; - private int threads; - private ClassLoader classLoader; - private int maxProblemsPerCheck = -1; - - private Builder(Locale locale) { - this.locale = locale; - } - - public Builder tempLocation(TempLocation tempLocation) { - this.tempLocation = tempLocation; - return this; - } - - public Builder threads(int threads) { - this.threads = threads; - return this; - } - - public Builder maxProblemsPerCheck(int maxProblemsPerCheck) { - this.maxProblemsPerCheck = maxProblemsPerCheck; - return this; - } - - public Builder classLoader(ClassLoader classLoader) { - this.classLoader = classLoader; - return this; - } - - public Linter build() { - TempLocation tempLocation = this.tempLocation; - - if (tempLocation == null) { - tempLocation = TempLocation.random(); - } - - return new Linter( - this.locale, - tempLocation, - this.threads, - this.classLoader, - this.maxProblemsPerCheck - ); - } - } - - public static Linter defaultLinter(Locale locale) { - return Linter.builder(locale).build(); - } - - public static Builder builder(Locale locale) { - return new Builder(locale); + this.tempLocation = builder.getTempLocation() != null ? (TempLocation) builder.getTempLocation() : TempLocation.random(); + this.threads = builder.getThreads(); + this.classLoader = builder.getClassLoader(); + this.maxProblemsPerCheck = builder.getMaxProblemsPerCheck(); } public FluentBundle getFluentBundle() { return fluentBundle; } + @Override + public List checkFile(Path file, JavaVersion version, CheckConfiguration checkConfiguration, Consumer statusConsumer) throws LinterException, IOException { + try (var uploadedFile = UploadedFile.build(file, version, this.tempLocation, statusConsumer, this.classLoader)) { + return this.checkFile(uploadedFile, checkConfiguration, statusConsumer); + } + } + public List checkFile( UploadedFile file, CheckConfiguration checkConfiguration, - Consumer statusConsumer + Consumer statusConsumer ) throws LinterException, IOException { var checks = this.findChecksForProblemTypes(checkConfiguration.problemsToReport()); return this.checkFile(file, checkConfiguration, checks, statusConsumer); } - private static List castUnsafe(Iterable list, Class clazz) { - List result = new ArrayList<>(); - - for (Object object : list) { - result.add(clazz.cast(object)); - } - - return result; - } - public List checkFile( UploadedFile file, CheckConfiguration checkConfiguration, Iterable checks, - Consumer statusConsumer + Consumer statusConsumer ) throws LinterException, IOException { // the file is null if the student did not upload source code if (file == null) { @@ -196,7 +145,7 @@ public List checkFile( } } - List unreducedProblems = result.problems(); + var unreducedProblems = result.problems(); if (!checkConfiguration.problemsToReport().isEmpty()) { unreducedProblems = result .problems() @@ -271,7 +220,7 @@ public String translateMessage(Translatable message) { .getTypesAnnotatedWith(ExecutableCheck.class) ); - public List findChecksForProblemTypes(Collection problems) { + public List findChecksForProblemTypes(Collection problems) { return CHECKS .stream() .filter(check -> isRequiredCheck(check.getAnnotation(ExecutableCheck.class), problems)) @@ -308,7 +257,17 @@ public List> findCodeLinter() { } - private boolean isRequiredCheck(ExecutableCheck check, Collection problems) { + private boolean isRequiredCheck(ExecutableCheck check, Collection problems) { return check.enabled() && problems.stream().anyMatch(p -> List.of(check.reportedProblems()).contains(p)); } + + private static List castUnsafe(Iterable list, Class clazz) { + List result = new ArrayList<>(); + + for (Object object : list) { + result.add(clazz.cast(object)); + } + + return result; + } } diff --git a/autograder-core/src/main/java/de/firemage/autograder/core/LocalizedMessage.java b/autograder-core/src/main/java/de/firemage/autograder/core/LocalizedMessage.java index 6613f42b..fc93c36a 100644 --- a/autograder-core/src/main/java/de/firemage/autograder/core/LocalizedMessage.java +++ b/autograder-core/src/main/java/de/firemage/autograder/core/LocalizedMessage.java @@ -1,5 +1,6 @@ package de.firemage.autograder.core; +import de.firemage.autograder.api.Translatable; import fluent.bundle.FluentBundle; import java.util.Map; diff --git a/autograder-core/src/main/java/de/firemage/autograder/core/MultiInCodeProblem.java b/autograder-core/src/main/java/de/firemage/autograder/core/MultiInCodeProblem.java index efbcfeef..48c0018e 100644 --- a/autograder-core/src/main/java/de/firemage/autograder/core/MultiInCodeProblem.java +++ b/autograder-core/src/main/java/de/firemage/autograder/core/MultiInCodeProblem.java @@ -1,5 +1,6 @@ package de.firemage.autograder.core; +import de.firemage.autograder.api.Translatable; import de.firemage.autograder.core.file.SourcePath; import org.apache.commons.io.FilenameUtils; @@ -11,7 +12,7 @@ import java.util.stream.Collectors; import java.util.stream.Stream; -public class MultiInCodeProblem extends ProblemImpl { +public class MultiInCodeProblem extends Problem { public MultiInCodeProblem( Problem firstProblem, diff --git a/autograder-core/src/main/java/de/firemage/autograder/core/Problem.java b/autograder-core/src/main/java/de/firemage/autograder/core/Problem.java index dcbc3170..3ffbe092 100644 --- a/autograder-core/src/main/java/de/firemage/autograder/core/Problem.java +++ b/autograder-core/src/main/java/de/firemage/autograder/core/Problem.java @@ -1,15 +1,69 @@ package de.firemage.autograder.core; +import de.firemage.autograder.api.AbstractProblem; +import de.firemage.autograder.api.Translatable; import de.firemage.autograder.core.check.Check; -public interface Problem { - Check getCheck(); +/** + * Contains the default implementation of most {@link AbstractProblem} methods. + */ +public abstract class Problem implements AbstractProblem { - Translatable getExplanation(); + private final Check check; - String getDisplayLocation(); + private final CodePosition position; - CodePosition getPosition(); + private final Translatable explanation; - ProblemType getProblemType(); + private final ProblemType problemType; + + protected Problem(Check check, CodePosition position, Translatable explanation, ProblemType problemType) { + this.check = check; + this.position = position; + this.explanation = explanation; + this.problemType = problemType; + } + + @Override + public String getDisplayLocation() { + // TODO + if (this.position.startLine() == this.position.endLine()) { + return this.position.file() + ":" + this.position.startLine(); + } else { + return this.position.file() + ":" + this.position.startLine() + "-" + this.position.endLine(); + } + } + + public Check getCheck() { + return check; + } + + @Override + public CodePosition getPosition() { + return position; + } + + @Override + public Translatable getExplanation() { + return explanation; + } + + @Override + public String getCheckName() { + return this.check.getClass().getSimpleName(); + } + + @Override + public Translatable getLinterName() { + return this.check.getLinter(); + } + + @Override + public String getType() { + return this.problemType.toString(); + } + + public ProblemType getProblemType() { + return problemType; + } } diff --git a/autograder-core/src/main/java/de/firemage/autograder/core/ProblemImpl.java b/autograder-core/src/main/java/de/firemage/autograder/core/ProblemImpl.java deleted file mode 100644 index df6eec99..00000000 --- a/autograder-core/src/main/java/de/firemage/autograder/core/ProblemImpl.java +++ /dev/null @@ -1,50 +0,0 @@ -package de.firemage.autograder.core; - -import de.firemage.autograder.core.check.Check; - -/** - * Contains the default implementation of most {@link Problem} methods. - */ -public abstract class ProblemImpl implements Problem { - - private final Check check; - - private final CodePosition position; - - private final Translatable explanation; - - private final ProblemType problemType; - - protected ProblemImpl(Check check, CodePosition position, Translatable explanation, ProblemType problemType) { - this.check = check; - this.position = position; - this.explanation = explanation; - this.problemType = problemType; - } - - @Override - public String getDisplayLocation() { - // TODO - if (this.position.startLine() == this.position.endLine()) { - return this.position.file() + ":" + this.position.startLine(); - } else { - return this.position.file() + ":" + this.position.startLine() + "-" + this.position.endLine(); - } - } - - public Check getCheck() { - return check; - } - - public CodePosition getPosition() { - return position; - } - - public Translatable getExplanation() { - return explanation; - } - - public ProblemType getProblemType() { - return problemType; - } -} diff --git a/autograder-core/src/main/java/de/firemage/autograder/core/ProblemType.java b/autograder-core/src/main/java/de/firemage/autograder/core/ProblemType.java index 31a49f37..c7c659a2 100644 --- a/autograder-core/src/main/java/de/firemage/autograder/core/ProblemType.java +++ b/autograder-core/src/main/java/de/firemage/autograder/core/ProblemType.java @@ -1,6 +1,12 @@ package de.firemage.autograder.core; -public enum ProblemType { +import de.firemage.autograder.api.AbstractProblemType; +import de.firemage.autograder.api.HasFalsePositives; + +import java.util.Collection; +import java.util.List; + +public enum ProblemType implements AbstractProblemType { /** * If the code is split into multiple packages, all input must happen in one package. Otherwise, one class must do all input. *
@@ -1048,5 +1054,14 @@ public enum ProblemType { * Reports code where a variable is declared, but not initialized. */ @HasFalsePositives - REDUNDANT_UNINITIALIZED_VARIABLE + REDUNDANT_UNINITIALIZED_VARIABLE; + + /** + * Used via reflection, so don't remove, even if your IDE shows no usages! + * @param name + * @return + */ + public static ProblemType fromString(String name) { + return ProblemType.valueOf(name); + } } diff --git a/autograder-core/src/main/java/de/firemage/autograder/core/check/Check.java b/autograder-core/src/main/java/de/firemage/autograder/core/check/Check.java index 10cfc47a..32202824 100644 --- a/autograder-core/src/main/java/de/firemage/autograder/core/check/Check.java +++ b/autograder-core/src/main/java/de/firemage/autograder/core/check/Check.java @@ -1,16 +1,15 @@ package de.firemage.autograder.core.check; -import de.firemage.autograder.core.Problem; -import de.firemage.autograder.core.LocalizedMessage; +import de.firemage.autograder.api.Translatable; import de.firemage.autograder.core.MultiInCodeProblem; +import de.firemage.autograder.core.Problem; import java.util.ArrayList; import java.util.List; import java.util.Optional; -@FunctionalInterface public interface Check { - LocalizedMessage getLinter(); + Translatable getLinter(); default List merge(List problems, int limit) { // use a dumb algorithm: keep the first limit - 1 problems, and merge the rest into a single problem diff --git a/autograder-core/src/main/java/de/firemage/autograder/core/check/api/AvoidStringConcat.java b/autograder-core/src/main/java/de/firemage/autograder/core/check/api/AvoidStringConcat.java index e6da056f..68a7708d 100644 --- a/autograder-core/src/main/java/de/firemage/autograder/core/check/api/AvoidStringConcat.java +++ b/autograder-core/src/main/java/de/firemage/autograder/core/check/api/AvoidStringConcat.java @@ -4,22 +4,13 @@ import de.firemage.autograder.core.LocalizedMessage; import de.firemage.autograder.core.ProblemType; import de.firemage.autograder.core.check.ExecutableCheck; -import de.firemage.autograder.core.integrated.CtRange; import de.firemage.autograder.core.integrated.IntegratedCheck; import de.firemage.autograder.core.integrated.SpoonUtil; import de.firemage.autograder.core.integrated.StaticAnalysis; -import org.apache.commons.lang3.Range; import spoon.processing.AbstractProcessor; -import spoon.reflect.code.BinaryOperatorKind; -import spoon.reflect.code.CtBinaryOperator; -import spoon.reflect.code.CtExpression; import spoon.reflect.code.CtInvocation; -import spoon.reflect.factory.Factory; -import spoon.reflect.reference.CtTypeReference; import java.util.Map; -import java.util.Optional; -import java.util.Set; @ExecutableCheck(reportedProblems = { ProblemType.AVOID_STRING_CONCAT }) public class AvoidStringConcat extends IntegratedCheck { diff --git a/autograder-core/src/main/java/de/firemage/autograder/core/check/comment/CommentedOutCodeCheck.java b/autograder-core/src/main/java/de/firemage/autograder/core/check/comment/CommentedOutCodeCheck.java index 8bb70b99..78ffe69c 100644 --- a/autograder-core/src/main/java/de/firemage/autograder/core/check/comment/CommentedOutCodeCheck.java +++ b/autograder-core/src/main/java/de/firemage/autograder/core/check/comment/CommentedOutCodeCheck.java @@ -3,7 +3,7 @@ import de.firemage.autograder.core.CodePosition; import de.firemage.autograder.core.LocalizedMessage; import de.firemage.autograder.core.ProblemType; -import de.firemage.autograder.core.Translatable; +import de.firemage.autograder.api.Translatable; import de.firemage.autograder.core.check.ExecutableCheck; import de.firemage.autograder.core.file.SourcePath; diff --git a/autograder-core/src/main/java/de/firemage/autograder/core/check/comment/ThrowsJavadocCheck.java b/autograder-core/src/main/java/de/firemage/autograder/core/check/comment/ThrowsJavadocCheck.java index 950396ff..0d885560 100644 --- a/autograder-core/src/main/java/de/firemage/autograder/core/check/comment/ThrowsJavadocCheck.java +++ b/autograder-core/src/main/java/de/firemage/autograder/core/check/comment/ThrowsJavadocCheck.java @@ -6,7 +6,6 @@ import de.firemage.autograder.core.integrated.IntegratedCheck; import de.firemage.autograder.core.integrated.SpoonUtil; import de.firemage.autograder.core.integrated.StaticAnalysis; -import spoon.reflect.code.CtAbstractSwitch; import spoon.reflect.code.CtCase; import spoon.reflect.code.CtConstructorCall; import spoon.reflect.code.CtJavaDoc; diff --git a/autograder-core/src/main/java/de/firemage/autograder/core/check/complexity/RedundantConstructorCheck.java b/autograder-core/src/main/java/de/firemage/autograder/core/check/complexity/RedundantConstructorCheck.java index efc64761..c98e9ac2 100644 --- a/autograder-core/src/main/java/de/firemage/autograder/core/check/complexity/RedundantConstructorCheck.java +++ b/autograder-core/src/main/java/de/firemage/autograder/core/check/complexity/RedundantConstructorCheck.java @@ -2,7 +2,7 @@ import de.firemage.autograder.core.LocalizedMessage; import de.firemage.autograder.core.ProblemType; -import de.firemage.autograder.core.Translatable; +import de.firemage.autograder.api.Translatable; import de.firemage.autograder.core.check.ExecutableCheck; import de.firemage.autograder.core.integrated.IntegratedCheck; import de.firemage.autograder.core.integrated.StaticAnalysis; diff --git a/autograder-core/src/main/java/de/firemage/autograder/core/check/complexity/RedundantNegationCheck.java b/autograder-core/src/main/java/de/firemage/autograder/core/check/complexity/RedundantNegationCheck.java index 90d2108d..761f1306 100644 --- a/autograder-core/src/main/java/de/firemage/autograder/core/check/complexity/RedundantNegationCheck.java +++ b/autograder-core/src/main/java/de/firemage/autograder/core/check/complexity/RedundantNegationCheck.java @@ -10,7 +10,6 @@ import de.firemage.autograder.core.integrated.evaluator.Evaluator; import de.firemage.autograder.core.integrated.evaluator.fold.Fold; import spoon.processing.AbstractProcessor; -import spoon.reflect.code.CtBinaryOperator; import spoon.reflect.code.CtExpression; import spoon.reflect.code.CtUnaryOperator; import spoon.reflect.code.UnaryOperatorKind; diff --git a/autograder-core/src/main/java/de/firemage/autograder/core/check/complexity/RepeatedMathOperationCheck.java b/autograder-core/src/main/java/de/firemage/autograder/core/check/complexity/RepeatedMathOperationCheck.java index ea40503b..15425d75 100644 --- a/autograder-core/src/main/java/de/firemage/autograder/core/check/complexity/RepeatedMathOperationCheck.java +++ b/autograder-core/src/main/java/de/firemage/autograder/core/check/complexity/RepeatedMathOperationCheck.java @@ -14,7 +14,6 @@ import spoon.reflect.code.CtExpression; import spoon.reflect.code.CtFieldRead; import spoon.reflect.code.CtVariableRead; -import spoon.reflect.code.UnaryOperatorKind; import spoon.reflect.declaration.CtElement; import spoon.reflect.factory.TypeFactory; import spoon.reflect.reference.CtVariableReference; diff --git a/autograder-core/src/main/java/de/firemage/autograder/core/check/general/OverrideAnnotationMissing.java b/autograder-core/src/main/java/de/firemage/autograder/core/check/general/OverrideAnnotationMissing.java index b9e0bd96..cb688b3b 100644 --- a/autograder-core/src/main/java/de/firemage/autograder/core/check/general/OverrideAnnotationMissing.java +++ b/autograder-core/src/main/java/de/firemage/autograder/core/check/general/OverrideAnnotationMissing.java @@ -5,7 +5,6 @@ import de.firemage.autograder.core.check.ExecutableCheck; import de.firemage.autograder.core.integrated.IntegratedCheck; import de.firemage.autograder.core.integrated.MethodHierarchy; -import de.firemage.autograder.core.integrated.SpoonUtil; import de.firemage.autograder.core.integrated.StaticAnalysis; import spoon.processing.AbstractProcessor; import spoon.reflect.declaration.CtMethod; diff --git a/autograder-core/src/main/java/de/firemage/autograder/core/check/naming/ConstantsHaveDescriptiveNamesCheck.java b/autograder-core/src/main/java/de/firemage/autograder/core/check/naming/ConstantsHaveDescriptiveNamesCheck.java index dea22dd6..6368155a 100644 --- a/autograder-core/src/main/java/de/firemage/autograder/core/check/naming/ConstantsHaveDescriptiveNamesCheck.java +++ b/autograder-core/src/main/java/de/firemage/autograder/core/check/naming/ConstantsHaveDescriptiveNamesCheck.java @@ -13,7 +13,6 @@ import spoon.reflect.declaration.CtField; import java.util.ArrayList; -import java.util.Arrays; import java.util.List; import java.util.Map; import java.util.Optional; diff --git a/autograder-core/src/main/java/de/firemage/autograder/core/check/naming/PackageNamingConvention.java b/autograder-core/src/main/java/de/firemage/autograder/core/check/naming/PackageNamingConvention.java index 96afca8a..86da3ab7 100644 --- a/autograder-core/src/main/java/de/firemage/autograder/core/check/naming/PackageNamingConvention.java +++ b/autograder-core/src/main/java/de/firemage/autograder/core/check/naming/PackageNamingConvention.java @@ -6,10 +6,8 @@ import de.firemage.autograder.core.integrated.IntegratedCheck; import de.firemage.autograder.core.integrated.SpoonUtil; import de.firemage.autograder.core.integrated.StaticAnalysis; -import spoon.processing.AbstractProcessor; import spoon.reflect.cu.SourcePosition; import spoon.reflect.declaration.CtCompilationUnit; -import spoon.reflect.declaration.CtElement; import spoon.reflect.declaration.CtPackageDeclaration; import spoon.reflect.declaration.CtType; diff --git a/autograder-core/src/main/java/de/firemage/autograder/core/check/oop/InstanceOf.java b/autograder-core/src/main/java/de/firemage/autograder/core/check/oop/InstanceOf.java index a733a017..8a097a9a 100644 --- a/autograder-core/src/main/java/de/firemage/autograder/core/check/oop/InstanceOf.java +++ b/autograder-core/src/main/java/de/firemage/autograder/core/check/oop/InstanceOf.java @@ -1,6 +1,5 @@ package de.firemage.autograder.core.check.oop; -import de.firemage.autograder.core.CodeModel; import de.firemage.autograder.core.LocalizedMessage; import de.firemage.autograder.core.ProblemType; import de.firemage.autograder.core.check.ExecutableCheck; diff --git a/autograder-core/src/main/java/de/firemage/autograder/core/compiler/CompilationFailureException.java b/autograder-core/src/main/java/de/firemage/autograder/core/compiler/CompilationFailureException.java index c574a478..0f61872a 100644 --- a/autograder-core/src/main/java/de/firemage/autograder/core/compiler/CompilationFailureException.java +++ b/autograder-core/src/main/java/de/firemage/autograder/core/compiler/CompilationFailureException.java @@ -1,6 +1,6 @@ package de.firemage.autograder.core.compiler; -import de.firemage.autograder.core.LinterException; +import de.firemage.autograder.api.LinterException; import java.util.List; diff --git a/autograder-core/src/main/java/de/firemage/autograder/core/compiler/Compiler.java b/autograder-core/src/main/java/de/firemage/autograder/core/compiler/Compiler.java index 5fc843c1..98d8878f 100644 --- a/autograder-core/src/main/java/de/firemage/autograder/core/compiler/Compiler.java +++ b/autograder-core/src/main/java/de/firemage/autograder/core/compiler/Compiler.java @@ -1,8 +1,9 @@ package de.firemage.autograder.core.compiler; +import de.firemage.autograder.api.JavaVersion; +import de.firemage.autograder.api.AbstractTempLocation; import de.firemage.autograder.core.file.CompilationUnit; import de.firemage.autograder.core.file.SourceInfo; -import de.firemage.autograder.core.file.TempLocation; import javax.tools.DiagnosticCollector; import javax.tools.JavaCompiler; @@ -29,7 +30,7 @@ import java.util.jar.Manifest; import java.util.regex.Pattern; -public record Compiler(TempLocation tempLocation, JavaVersion javaVersion) { +public record Compiler(AbstractTempLocation tempLocation, JavaVersion javaVersion) { static final Locale COMPILER_LOCALE = Locale.US; public Optional compileToJar(SourceInfo input) throws IOException, CompilationFailureException { @@ -44,7 +45,7 @@ private Optional compileAndIgnoreSuppressWarnings( SourceInfo input ) throws IOException, CompilationFailureException { Optional compilationResult; - try (TempLocation modifiedOutput = this.tempLocation.createTempDirectory(input.getName() + "_modified")) { + try (AbstractTempLocation modifiedOutput = this.tempLocation.createTempDirectory(input.getName() + "_modified")) { SourceInfo copiedVersion = input.copyTo(modifiedOutput.toPath()); List compilationUnits = copiedVersion.compilationUnits(); @@ -108,7 +109,7 @@ private Optional compile(SourceInfo input) throws IOException List diagnostics = new ArrayList<>(); Path jar; - try (TempLocation compilerOutput = this.tempLocation.createTempDirectory(input.getName() + "_compiled")) { + try (AbstractTempLocation compilerOutput = this.tempLocation.createTempDirectory(input.getName() + "_compiled")) { JavaFileManager fileManager = new SeparateBinaryFileManager( compiler.getStandardFileManager(diagnosticCollector, Locale.US, charset), compilerOutput.toPath().toFile(), diff --git a/autograder-core/src/main/java/de/firemage/autograder/core/file/FileSourceInfo.java b/autograder-core/src/main/java/de/firemage/autograder/core/file/FileSourceInfo.java index 6be3eb7b..c3872cc2 100644 --- a/autograder-core/src/main/java/de/firemage/autograder/core/file/FileSourceInfo.java +++ b/autograder-core/src/main/java/de/firemage/autograder/core/file/FileSourceInfo.java @@ -1,7 +1,7 @@ package de.firemage.autograder.core.file; import de.firemage.autograder.core.SerializableCharset; -import de.firemage.autograder.core.compiler.JavaVersion; +import de.firemage.autograder.api.JavaVersion; import de.firemage.autograder.core.compiler.PhysicalFileObject; import org.apache.commons.io.FileUtils; import org.mozilla.universalchardet.UniversalDetector; diff --git a/autograder-core/src/main/java/de/firemage/autograder/core/file/SourceInfo.java b/autograder-core/src/main/java/de/firemage/autograder/core/file/SourceInfo.java index be0c66fb..ba6e8b3f 100644 --- a/autograder-core/src/main/java/de/firemage/autograder/core/file/SourceInfo.java +++ b/autograder-core/src/main/java/de/firemage/autograder/core/file/SourceInfo.java @@ -1,6 +1,6 @@ package de.firemage.autograder.core.file; -import de.firemage.autograder.core.compiler.JavaVersion; +import de.firemage.autograder.api.JavaVersion; import spoon.compiler.SpoonResource; import java.io.IOException; diff --git a/autograder-core/src/main/java/de/firemage/autograder/core/file/SourcePath.java b/autograder-core/src/main/java/de/firemage/autograder/core/file/SourcePath.java index 05d31daf..67a304b6 100644 --- a/autograder-core/src/main/java/de/firemage/autograder/core/file/SourcePath.java +++ b/autograder-core/src/main/java/de/firemage/autograder/core/file/SourcePath.java @@ -1,5 +1,7 @@ package de.firemage.autograder.core.file; +import de.firemage.autograder.api.PathLike; + import java.io.Serializable; import java.nio.file.Path; import java.util.ArrayList; @@ -18,7 +20,7 @@ * Additionally, it would be possible to have paths with {@code ".."} that have to be normalized first, which * makes comparisons harder. */ -public final class SourcePath implements Comparable, Serializable { +public final class SourcePath implements Comparable, Serializable, PathLike { private static final String SEPARATOR = "/"; private final List segments; diff --git a/autograder-core/src/main/java/de/firemage/autograder/core/file/StringSourceInfo.java b/autograder-core/src/main/java/de/firemage/autograder/core/file/StringSourceInfo.java index 913678a1..fa93aaec 100644 --- a/autograder-core/src/main/java/de/firemage/autograder/core/file/StringSourceInfo.java +++ b/autograder-core/src/main/java/de/firemage/autograder/core/file/StringSourceInfo.java @@ -1,6 +1,6 @@ package de.firemage.autograder.core.file; -import de.firemage.autograder.core.compiler.JavaVersion; +import de.firemage.autograder.api.JavaVersion; import org.apache.commons.io.FileUtils; import spoon.compiler.SpoonResource; import spoon.support.compiler.VirtualFile; diff --git a/autograder-core/src/main/java/de/firemage/autograder/core/file/TempLocation.java b/autograder-core/src/main/java/de/firemage/autograder/core/file/TempLocation.java index 35007e7f..9b027df1 100644 --- a/autograder-core/src/main/java/de/firemage/autograder/core/file/TempLocation.java +++ b/autograder-core/src/main/java/de/firemage/autograder/core/file/TempLocation.java @@ -1,34 +1,40 @@ package de.firemage.autograder.core.file; +import de.firemage.autograder.api.AbstractTempLocation; import org.apache.commons.io.FileUtils; -import java.io.Closeable; import java.io.File; import java.io.IOException; -import java.io.Serializable; import java.nio.file.Files; import java.nio.file.Path; import java.util.List; import java.util.Random; -public record TempLocation(File tempLocation) implements Serializable, Closeable { +public record TempLocation(File tempLocation) implements AbstractTempLocation { private static final Random RANDOM = new Random(); private static final String TEMPORARY_DIR_FORMAT = "%s%d"; - public static TempLocation fromPath(Path path) { - return new TempLocation(path.toFile()); + public static TempLocation random() { + return new TempLocation(); } - public static TempLocation of(String first, String... other) { - return TempLocation.fromPath(Path.of(first, other)); + public static TempLocation of(Path path) { + return new TempLocation(path); } - public static TempLocation random() { - try { - return TempLocation.fromPath(Files.createTempDirectory("random")); - } catch (IOException e) { - throw new IllegalStateException("Could not create temporary directory", e); - } + public TempLocation(Path path) { + this(path.toFile()); + } + + public TempLocation(String first, String... other) { + this(Path.of(first, other).toFile()); + } + + /** + * Creates a new random temporary location (same as {@link TempLocation#random()}). + */ + public TempLocation() { + this(tryCreateTempDirectory()); } /** @@ -70,13 +76,14 @@ private static Path makeDirectory(Path path, String prefix) throws IOException { return Files.createDirectory(directory); } + @Override public TempLocation createTempDirectory(String prefix) throws IOException { if (prefix.contains(File.pathSeparator)) { throw new IllegalArgumentException("the prefix '%s' contains a path separator".formatted(prefix)); } for (IOFunction tempDir : this.temporaryDirectories()) { try { - return TempLocation.fromPath(tempDir.apply(prefix)); + return new TempLocation(tempDir.apply(prefix)); } catch (IOException exception) { // this will fail if there is no read/write-access to the directory } @@ -85,6 +92,7 @@ public TempLocation createTempDirectory(String prefix) throws IOException { throw new IllegalStateException("could not find a temporary directory"); } + @Override public Path createTempFile(String name) throws IOException { // fix conflicts by adding a random number to the name (e.g. "file.txt" -> "123456789file.txt") Path path = this.toPath().resolve(name); @@ -99,6 +107,7 @@ public Path createTempFile(String name) throws IOException { * Returns the path of the temporary location. * @return the path of the temporary location */ + @Override public Path toPath() { return this.tempLocation.toPath(); } @@ -113,4 +122,12 @@ public void close() throws IOException { // delete the temporary directory, will not crash if it fails to delete it FileUtils.forceDeleteOnExit(this.toPath().toFile()); } + + private static File tryCreateTempDirectory() { + try { + return Files.createTempDirectory("random").toFile(); + } catch (IOException e) { + throw new IllegalStateException("Could not create temporary directory", e); + } + } } diff --git a/autograder-core/src/main/java/de/firemage/autograder/core/file/UploadedFile.java b/autograder-core/src/main/java/de/firemage/autograder/core/file/UploadedFile.java index 0bcd204c..aa9b22e4 100644 --- a/autograder-core/src/main/java/de/firemage/autograder/core/file/UploadedFile.java +++ b/autograder-core/src/main/java/de/firemage/autograder/core/file/UploadedFile.java @@ -1,11 +1,13 @@ package de.firemage.autograder.core.file; +import de.firemage.autograder.api.AbstractTempLocation; +import de.firemage.autograder.api.Translatable; import de.firemage.autograder.core.CodeModel; import de.firemage.autograder.core.LinterStatus; import de.firemage.autograder.core.compiler.CompilationFailureException; import de.firemage.autograder.core.compiler.CompilationResult; import de.firemage.autograder.core.compiler.Compiler; -import de.firemage.autograder.core.compiler.JavaVersion; +import de.firemage.autograder.api.JavaVersion; import de.firemage.autograder.core.integrated.ModelBuildException; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -22,9 +24,9 @@ public final class UploadedFile implements AutoCloseable { private final SourceInfo source; private final CompilationResult compilationResult; private final ClassLoader classLoader; - private final TempLocation tempLocation; + private final AbstractTempLocation tempLocation; - private UploadedFile(CodeModel model, SourceInfo source, CompilationResult compilationResult, ClassLoader classLoader, TempLocation tempLocation) { + private UploadedFile(CodeModel model, SourceInfo source, CompilationResult compilationResult, ClassLoader classLoader, AbstractTempLocation tempLocation) { this.model = model; this.source = source; this.compilationResult = compilationResult; @@ -43,8 +45,8 @@ public UploadedFile copy() { public static UploadedFile build( Path file, JavaVersion version, - TempLocation tmpLocation, - Consumer statusConsumer, + AbstractTempLocation tmpLocation, + Consumer statusConsumer, ClassLoader classLoader ) throws IOException, ModelBuildException, CompilationFailureException { return UploadedFile.build(new FileSourceInfo(file, version), tmpLocation, statusConsumer, classLoader); @@ -52,12 +54,12 @@ public static UploadedFile build( public static UploadedFile build( SourceInfo source, - TempLocation tmpLocation, - Consumer statusConsumer, + AbstractTempLocation tmpLocation, + Consumer statusConsumer, ClassLoader classLoader ) throws IOException, CompilationFailureException { Compiler compiler = new Compiler(tmpLocation, source.getVersion()); - statusConsumer.accept(LinterStatus.COMPILING); + statusConsumer.accept(LinterStatus.COMPILING.getMessage()); Optional compilationResult = compiler.compileToJar(source); if (compilationResult.isEmpty()) { return null; diff --git a/autograder-core/src/main/java/de/firemage/autograder/core/file/ZipFormatException.java b/autograder-core/src/main/java/de/firemage/autograder/core/file/ZipFormatException.java deleted file mode 100644 index a6865ef5..00000000 --- a/autograder-core/src/main/java/de/firemage/autograder/core/file/ZipFormatException.java +++ /dev/null @@ -1,20 +0,0 @@ -package de.firemage.autograder.core.file; - -import de.firemage.autograder.core.LinterException; - -public class ZipFormatException extends LinterException { - public ZipFormatException() { - } - - public ZipFormatException(String message) { - super(message); - } - - public ZipFormatException(String message, Throwable cause) { - super(message, cause); - } - - public ZipFormatException(Throwable cause) { - super(cause); - } -} diff --git a/autograder-core/src/main/java/de/firemage/autograder/core/integrated/IntegratedAnalysis.java b/autograder-core/src/main/java/de/firemage/autograder/core/integrated/IntegratedAnalysis.java index 15c5b933..85f114ca 100644 --- a/autograder-core/src/main/java/de/firemage/autograder/core/integrated/IntegratedAnalysis.java +++ b/autograder-core/src/main/java/de/firemage/autograder/core/integrated/IntegratedAnalysis.java @@ -1,11 +1,11 @@ package de.firemage.autograder.core.integrated; +import de.firemage.autograder.api.Translatable; import de.firemage.autograder.core.CodeLinter; import de.firemage.autograder.core.LinterStatus; +import de.firemage.autograder.api.AbstractTempLocation; import de.firemage.autograder.core.Problem; -import de.firemage.autograder.core.file.TempLocation; import de.firemage.autograder.core.file.UploadedFile; -import de.firemage.autograder.core.parallel.AnalysisScheduler; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import spoon.reflect.CtModel; @@ -65,17 +65,17 @@ public Class supportedCheckType() { @Override public List lint( UploadedFile submission, - TempLocation tempLocation, + AbstractTempLocation tempLocation, ClassLoader classLoader, List checks, - Consumer statusConsumer + Consumer statusConsumer ) { this.init(submission); - statusConsumer.accept(LinterStatus.BUILDING_CODE_MODEL); + statusConsumer.accept(LinterStatus.BUILDING_CODE_MODEL.getMessage()); this.staticAnalysis.getCodeModel().ensureModelBuild(); - statusConsumer.accept(LinterStatus.RUNNING_INTEGRATED_CHECKS); + statusConsumer.accept(LinterStatus.RUNNING_INTEGRATED_CHECKS.getMessage()); List result = new ArrayList<>(); for (IntegratedCheck check : checks) { diff --git a/autograder-core/src/main/java/de/firemage/autograder/core/integrated/IntegratedCheck.java b/autograder-core/src/main/java/de/firemage/autograder/core/integrated/IntegratedCheck.java index 0a38b2e9..b0b2c28c 100644 --- a/autograder-core/src/main/java/de/firemage/autograder/core/integrated/IntegratedCheck.java +++ b/autograder-core/src/main/java/de/firemage/autograder/core/integrated/IntegratedCheck.java @@ -1,11 +1,10 @@ package de.firemage.autograder.core.integrated; import de.firemage.autograder.core.CodePosition; -import de.firemage.autograder.core.ProblemImpl; -import de.firemage.autograder.core.LocalizedMessage; import de.firemage.autograder.core.Problem; +import de.firemage.autograder.core.LocalizedMessage; import de.firemage.autograder.core.ProblemType; -import de.firemage.autograder.core.Translatable; +import de.firemage.autograder.api.Translatable; import de.firemage.autograder.core.check.Check; import de.firemage.autograder.core.file.SourceInfo; import spoon.reflect.declaration.CtElement; @@ -24,7 +23,7 @@ protected void addLocalProblem(CtElement element, Translatable explanation, Prob } protected void addLocalProblem(CodePosition position, Translatable explanation, ProblemType problemType) { - this.problems.add(new ProblemImpl(this, position, explanation, problemType) {}); + this.problems.add(new Problem(this, position, explanation, problemType) {}); } public List run(StaticAnalysis staticAnalysis, SourceInfo sourceInfo) { @@ -37,7 +36,7 @@ public List run(StaticAnalysis staticAnalysis, SourceInfo sourceInfo) { protected abstract void check(StaticAnalysis staticAnalysis); @Override - public LocalizedMessage getLinter() { + public Translatable getLinter() { return new LocalizedMessage("linter-integrated"); } diff --git a/autograder-core/src/main/java/de/firemage/autograder/core/integrated/IntegratedInCodeProblem.java b/autograder-core/src/main/java/de/firemage/autograder/core/integrated/IntegratedInCodeProblem.java index 6b4faf88..ddc254d3 100644 --- a/autograder-core/src/main/java/de/firemage/autograder/core/integrated/IntegratedInCodeProblem.java +++ b/autograder-core/src/main/java/de/firemage/autograder/core/integrated/IntegratedInCodeProblem.java @@ -1,14 +1,14 @@ package de.firemage.autograder.core.integrated; import de.firemage.autograder.core.CodePosition; -import de.firemage.autograder.core.ProblemImpl; +import de.firemage.autograder.core.Problem; import de.firemage.autograder.core.ProblemType; -import de.firemage.autograder.core.Translatable; +import de.firemage.autograder.api.Translatable; import de.firemage.autograder.core.check.Check; import de.firemage.autograder.core.file.SourceInfo; import spoon.reflect.declaration.CtElement; -public class IntegratedInCodeProblem extends ProblemImpl { +public class IntegratedInCodeProblem extends Problem { private final CtElement element; public IntegratedInCodeProblem(Check check, CtElement element, Translatable explanation, diff --git a/autograder-core/src/main/java/de/firemage/autograder/core/integrated/ModelBuildException.java b/autograder-core/src/main/java/de/firemage/autograder/core/integrated/ModelBuildException.java index 64a1f2d1..41d945e0 100644 --- a/autograder-core/src/main/java/de/firemage/autograder/core/integrated/ModelBuildException.java +++ b/autograder-core/src/main/java/de/firemage/autograder/core/integrated/ModelBuildException.java @@ -1,6 +1,6 @@ package de.firemage.autograder.core.integrated; -import de.firemage.autograder.core.LinterException; +import de.firemage.autograder.api.LinterException; public class ModelBuildException extends LinterException { public ModelBuildException(String message, Throwable cause) { diff --git a/autograder-core/src/test/java/de/firemage/autograder/core/CheckTest.java b/autograder-core/src/test/java/de/firemage/autograder/core/CheckTest.java index 8c95da5b..3a1784db 100644 --- a/autograder-core/src/test/java/de/firemage/autograder/core/CheckTest.java +++ b/autograder-core/src/test/java/de/firemage/autograder/core/CheckTest.java @@ -1,7 +1,10 @@ package de.firemage.autograder.core; +import de.firemage.autograder.api.CheckConfiguration; +import de.firemage.autograder.api.JavaVersion; +import de.firemage.autograder.api.AbstractLinter; +import de.firemage.autograder.api.AbstractTempLocation; import de.firemage.autograder.core.check.Check; -import de.firemage.autograder.core.compiler.JavaVersion; import de.firemage.autograder.core.file.TempLocation; import de.firemage.autograder.core.file.UploadedFile; import org.junit.jupiter.api.DynamicTest; @@ -91,7 +94,7 @@ Stream createCheckTest() throws URISyntaxException, IOException { folders = paths.toList(); } - TempLocation tempLocation = TempLocation.random(); + AbstractTempLocation tempLocation = TempLocation.random(); return DynamicTest.stream( folders.stream().map(TestInput::fromPath) @@ -101,17 +104,16 @@ Stream createCheckTest() throws URISyntaxException, IOException { var check = testInput.config().check(); var expectedProblems = testInput.config().expectedProblems(); - try (TempLocation tmpDirectory = tempLocation.createTempDirectory(testInput.config().checkPath())) { + try (AbstractTempLocation tmpDirectory = tempLocation.createTempDirectory(testInput.config().checkPath())) { var file = UploadedFile.build( testInput.path().resolve("code"), JavaVersion.JAVA_17, tmpDirectory, status -> { }, null ); - var linter = Linter.builder(Locale.US) + var linter = new Linter(AbstractLinter.builder(Locale.US) .threads(1) // Use a single thread for performance reasons - .tempLocation(tmpDirectory) - .build(); + .tempLocation(tmpDirectory)); var problems = linter.checkFile( file, diff --git a/autograder-core/src/test/java/de/firemage/autograder/core/TestSampleConfig.java b/autograder-core/src/test/java/de/firemage/autograder/core/TestSampleConfig.java index 67548b89..9920ee35 100644 --- a/autograder-core/src/test/java/de/firemage/autograder/core/TestSampleConfig.java +++ b/autograder-core/src/test/java/de/firemage/autograder/core/TestSampleConfig.java @@ -1,5 +1,8 @@ package de.firemage.autograder.core; +import de.firemage.autograder.api.AbstractProblemType; +import de.firemage.autograder.api.CheckConfiguration; +import de.firemage.autograder.api.LinterConfigurationException; import org.junit.jupiter.api.Test; import java.io.IOException; @@ -13,11 +16,11 @@ import static org.junit.jupiter.api.Assertions.fail; class TestSampleConfig { - private static > void assertProblemTypes(List expected, List actual) { - Collection actualSet = new TreeSet<>(actual); + private static void assertProblemTypes(List expected, List actual) { + var actualSet = new TreeSet<>(actual); - Collection difference = new ArrayList<>(); - for (T value : expected) { + Collection difference = new ArrayList<>(); + for (AbstractProblemType value : expected) { if (!actualSet.remove(value)) { difference.add(value); } @@ -36,7 +39,7 @@ private static > void assertProblemTypes(List void hasAllProblemTypes() throws IOException, LinterConfigurationException { // the `System.getProperty("user.dir")` is the path to the autograder-core directory Path path = Path.of(System.getProperty("user.dir"), "..", "sample_config.yaml"); - List present = CheckConfiguration.fromConfigFile(path).problemsToReport(); + var present = CheckConfiguration.fromConfigFile(path).problemsToReport(); assertProblemTypes(Arrays.asList(ProblemType.values()), present); } diff --git a/autograder-core/src/test/java/de/firemage/autograder/core/check/AbstractCheckTest.java b/autograder-core/src/test/java/de/firemage/autograder/core/check/AbstractCheckTest.java index 3b88bc27..93aebe27 100644 --- a/autograder-core/src/test/java/de/firemage/autograder/core/check/AbstractCheckTest.java +++ b/autograder-core/src/test/java/de/firemage/autograder/core/check/AbstractCheckTest.java @@ -1,8 +1,10 @@ package de.firemage.autograder.core.check; -import de.firemage.autograder.core.CheckConfiguration; +import de.firemage.autograder.api.AbstractLinter; +import de.firemage.autograder.api.AbstractProblemType; +import de.firemage.autograder.api.CheckConfiguration; +import de.firemage.autograder.api.LinterException; import de.firemage.autograder.core.Linter; -import de.firemage.autograder.core.LinterException; import de.firemage.autograder.core.Problem; import de.firemage.autograder.core.ProblemType; import de.firemage.autograder.core.file.SourceInfo; @@ -32,16 +34,15 @@ protected AbstractCheckTest(int limit) { private AbstractCheckTest(TempLocation tempLocation, int limit) { this.tempLocation = tempLocation; - this.linter = Linter.builder(Locale.US) + this.linter = new Linter(AbstractLinter.builder(Locale.US) .tempLocation(this.tempLocation) .maxProblemsPerCheck(limit) - .threads(1) - .build(); + .threads(1)); } protected List check( SourceInfo sourceInfo, - List problemTypes + List problemTypes ) throws LinterException, IOException { return this.linter.checkFile( UploadedFile.build(sourceInfo, this.tempLocation, status -> { diff --git a/autograder-core/src/test/java/de/firemage/autograder/core/check/TestMergedProblems.java b/autograder-core/src/test/java/de/firemage/autograder/core/check/TestMergedProblems.java index e67f1455..7af77f22 100644 --- a/autograder-core/src/test/java/de/firemage/autograder/core/check/TestMergedProblems.java +++ b/autograder-core/src/test/java/de/firemage/autograder/core/check/TestMergedProblems.java @@ -1,11 +1,10 @@ package de.firemage.autograder.core.check; -import de.firemage.autograder.core.LinterException; +import de.firemage.autograder.api.LinterException; import de.firemage.autograder.core.LocalizedMessage; -import de.firemage.autograder.core.Problem; import de.firemage.autograder.core.ProblemType; import de.firemage.autograder.core.file.StringSourceInfo; -import de.firemage.autograder.core.compiler.JavaVersion; +import de.firemage.autograder.api.JavaVersion; import org.junit.jupiter.api.Test; import java.io.IOException; @@ -31,7 +30,7 @@ private static Stream generateViolations(int count) { void testMergeSingleFile() throws LinterException, IOException { List fields = generateViolations(10).toList(); - List problems = super.check(StringSourceInfo.fromSourceStrings( + var problems = super.check(StringSourceInfo.fromSourceStrings( JavaVersion.JAVA_17, Map.ofEntries( Map.entry( @@ -78,7 +77,7 @@ public static void main(String[] args) {} void testMergeMultiFile() throws LinterException, IOException { List fields = generateViolations(10).toList(); - List problems = super.check(StringSourceInfo.fromSourceStrings( + var problems = super.check(StringSourceInfo.fromSourceStrings( JavaVersion.JAVA_17, Map.ofEntries( Map.entry( @@ -136,7 +135,7 @@ public class Vector { void testMergeSingleViolationInFile() throws LinterException, IOException { List fields = generateViolations(10).toList(); - List problems = super.check(StringSourceInfo.fromSourceStrings( + var problems = super.check(StringSourceInfo.fromSourceStrings( JavaVersion.JAVA_17, Map.ofEntries( Map.entry( diff --git a/autograder-core/src/test/java/de/firemage/autograder/core/check/api/TestAvoidStringConcat.java b/autograder-core/src/test/java/de/firemage/autograder/core/check/api/TestAvoidStringConcat.java index aa37f542..18f84fe1 100644 --- a/autograder-core/src/test/java/de/firemage/autograder/core/check/api/TestAvoidStringConcat.java +++ b/autograder-core/src/test/java/de/firemage/autograder/core/check/api/TestAvoidStringConcat.java @@ -1,11 +1,11 @@ package de.firemage.autograder.core.check.api; -import de.firemage.autograder.core.LinterException; +import de.firemage.autograder.api.JavaVersion; +import de.firemage.autograder.api.LinterException; import de.firemage.autograder.core.LocalizedMessage; import de.firemage.autograder.core.Problem; import de.firemage.autograder.core.ProblemType; import de.firemage.autograder.core.check.AbstractCheckTest; -import de.firemage.autograder.core.compiler.JavaVersion; import de.firemage.autograder.core.file.StringSourceInfo; import org.junit.jupiter.api.Test; diff --git a/autograder-core/src/test/java/de/firemage/autograder/core/check/api/TestCharRange.java b/autograder-core/src/test/java/de/firemage/autograder/core/check/api/TestCharRange.java index 27f585e9..7c5be95a 100644 --- a/autograder-core/src/test/java/de/firemage/autograder/core/check/api/TestCharRange.java +++ b/autograder-core/src/test/java/de/firemage/autograder/core/check/api/TestCharRange.java @@ -1,12 +1,11 @@ package de.firemage.autograder.core.check.api; -import de.firemage.autograder.core.LinterException; +import de.firemage.autograder.api.LinterException; import de.firemage.autograder.core.LocalizedMessage; -import de.firemage.autograder.core.Problem; import de.firemage.autograder.core.ProblemType; import de.firemage.autograder.core.file.StringSourceInfo; import de.firemage.autograder.core.check.AbstractCheckTest; -import de.firemage.autograder.core.compiler.JavaVersion; +import de.firemage.autograder.api.JavaVersion; import org.junit.jupiter.api.Test; import java.io.IOException; @@ -20,7 +19,7 @@ public class TestCharRange extends AbstractCheckTest { @Test void testIsDigit() throws LinterException, IOException { - List problems = super.check(StringSourceInfo.fromSourceString( + var problems = super.check(StringSourceInfo.fromSourceString( JavaVersion.JAVA_17, "Test", """ @@ -49,7 +48,7 @@ public static boolean isNumber(char input) { @Test void testIsLowerCase() throws LinterException, IOException { - List problems = super.check(StringSourceInfo.fromSourceString( + var problems = super.check(StringSourceInfo.fromSourceString( JavaVersion.JAVA_17, "Test", """ @@ -78,7 +77,7 @@ public static boolean isLowerCase(char c) { @Test void testIsNotLowerCase() throws LinterException, IOException { - List problems = super.check(StringSourceInfo.fromSourceString( + var problems = super.check(StringSourceInfo.fromSourceString( JavaVersion.JAVA_17, "Test", """ @@ -107,7 +106,7 @@ public static boolean isNotLowerCase(char c) { @Test void testNormalization() throws LinterException, IOException { - List problems = super.check(StringSourceInfo.fromSourceString( + var problems = super.check(StringSourceInfo.fromSourceString( JavaVersion.JAVA_17, "Test", """ @@ -135,7 +134,7 @@ public static boolean isLowerCase(char c) { @Test void testIsUpperCase() throws LinterException, IOException { - List problems = super.check(StringSourceInfo.fromSourceString( + var problems = super.check(StringSourceInfo.fromSourceString( JavaVersion.JAVA_17, "Test", """ diff --git a/autograder-core/src/test/java/de/firemage/autograder/core/check/api/TestCheckIterableDuplicates.java b/autograder-core/src/test/java/de/firemage/autograder/core/check/api/TestCheckIterableDuplicates.java index 98ed0640..a547e478 100644 --- a/autograder-core/src/test/java/de/firemage/autograder/core/check/api/TestCheckIterableDuplicates.java +++ b/autograder-core/src/test/java/de/firemage/autograder/core/check/api/TestCheckIterableDuplicates.java @@ -1,11 +1,11 @@ package de.firemage.autograder.core.check.api; -import de.firemage.autograder.core.LinterException; +import de.firemage.autograder.api.LinterException; import de.firemage.autograder.core.LocalizedMessage; import de.firemage.autograder.core.Problem; import de.firemage.autograder.core.ProblemType; import de.firemage.autograder.core.check.AbstractCheckTest; -import de.firemage.autograder.core.compiler.JavaVersion; +import de.firemage.autograder.api.JavaVersion; import de.firemage.autograder.core.file.StringSourceInfo; import org.junit.jupiter.api.Test; diff --git a/autograder-core/src/test/java/de/firemage/autograder/core/check/api/TestCollectionAddAll.java b/autograder-core/src/test/java/de/firemage/autograder/core/check/api/TestCollectionAddAll.java index f9528854..6e0c2b74 100644 --- a/autograder-core/src/test/java/de/firemage/autograder/core/check/api/TestCollectionAddAll.java +++ b/autograder-core/src/test/java/de/firemage/autograder/core/check/api/TestCollectionAddAll.java @@ -1,11 +1,11 @@ package de.firemage.autograder.core.check.api; -import de.firemage.autograder.core.LinterException; +import de.firemage.autograder.api.LinterException; import de.firemage.autograder.core.LocalizedMessage; import de.firemage.autograder.core.Problem; import de.firemage.autograder.core.ProblemType; import de.firemage.autograder.core.check.AbstractCheckTest; -import de.firemage.autograder.core.compiler.JavaVersion; +import de.firemage.autograder.api.JavaVersion; import de.firemage.autograder.core.file.StringSourceInfo; import org.junit.jupiter.api.Test; diff --git a/autograder-core/src/test/java/de/firemage/autograder/core/check/api/TestCollectionsNCopies.java b/autograder-core/src/test/java/de/firemage/autograder/core/check/api/TestCollectionsNCopies.java index 698dfdb5..2f284c31 100644 --- a/autograder-core/src/test/java/de/firemage/autograder/core/check/api/TestCollectionsNCopies.java +++ b/autograder-core/src/test/java/de/firemage/autograder/core/check/api/TestCollectionsNCopies.java @@ -1,11 +1,11 @@ package de.firemage.autograder.core.check.api; -import de.firemage.autograder.core.LinterException; +import de.firemage.autograder.api.LinterException; import de.firemage.autograder.core.LocalizedMessage; import de.firemage.autograder.core.Problem; import de.firemage.autograder.core.ProblemType; import de.firemage.autograder.core.check.AbstractCheckTest; -import de.firemage.autograder.core.compiler.JavaVersion; +import de.firemage.autograder.api.JavaVersion; import de.firemage.autograder.core.file.StringSourceInfo; import org.junit.jupiter.api.Test; diff --git a/autograder-core/src/test/java/de/firemage/autograder/core/check/api/TestImplementComparable.java b/autograder-core/src/test/java/de/firemage/autograder/core/check/api/TestImplementComparable.java index 02624085..4b15c7bc 100644 --- a/autograder-core/src/test/java/de/firemage/autograder/core/check/api/TestImplementComparable.java +++ b/autograder-core/src/test/java/de/firemage/autograder/core/check/api/TestImplementComparable.java @@ -1,11 +1,11 @@ package de.firemage.autograder.core.check.api; -import de.firemage.autograder.core.LinterException; +import de.firemage.autograder.api.LinterException; import de.firemage.autograder.core.LocalizedMessage; import de.firemage.autograder.core.Problem; import de.firemage.autograder.core.ProblemType; import de.firemage.autograder.core.check.AbstractCheckTest; -import de.firemage.autograder.core.compiler.JavaVersion; +import de.firemage.autograder.api.JavaVersion; import de.firemage.autograder.core.file.StringSourceInfo; import org.junit.jupiter.api.Test; diff --git a/autograder-core/src/test/java/de/firemage/autograder/core/check/api/TestIsEmptyReimplementationCheck.java b/autograder-core/src/test/java/de/firemage/autograder/core/check/api/TestIsEmptyReimplementationCheck.java index 760a1580..a757c6d3 100644 --- a/autograder-core/src/test/java/de/firemage/autograder/core/check/api/TestIsEmptyReimplementationCheck.java +++ b/autograder-core/src/test/java/de/firemage/autograder/core/check/api/TestIsEmptyReimplementationCheck.java @@ -1,11 +1,11 @@ package de.firemage.autograder.core.check.api; -import de.firemage.autograder.core.LinterException; +import de.firemage.autograder.api.LinterException; import de.firemage.autograder.core.LocalizedMessage; import de.firemage.autograder.core.Problem; import de.firemage.autograder.core.ProblemType; import de.firemage.autograder.core.check.AbstractCheckTest; -import de.firemage.autograder.core.compiler.JavaVersion; +import de.firemage.autograder.api.JavaVersion; import de.firemage.autograder.core.file.StringSourceInfo; import org.junit.jupiter.api.Test; import org.junit.jupiter.params.ParameterizedTest; diff --git a/autograder-core/src/test/java/de/firemage/autograder/core/check/api/TestMathReimplementation.java b/autograder-core/src/test/java/de/firemage/autograder/core/check/api/TestMathReimplementation.java index b760ac8c..cc206409 100644 --- a/autograder-core/src/test/java/de/firemage/autograder/core/check/api/TestMathReimplementation.java +++ b/autograder-core/src/test/java/de/firemage/autograder/core/check/api/TestMathReimplementation.java @@ -1,11 +1,11 @@ package de.firemage.autograder.core.check.api; -import de.firemage.autograder.core.LinterException; +import de.firemage.autograder.api.LinterException; import de.firemage.autograder.core.LocalizedMessage; import de.firemage.autograder.core.Problem; import de.firemage.autograder.core.ProblemType; import de.firemage.autograder.core.check.AbstractCheckTest; -import de.firemage.autograder.core.compiler.JavaVersion; +import de.firemage.autograder.api.JavaVersion; import de.firemage.autograder.core.file.StringSourceInfo; import org.junit.jupiter.api.Test; diff --git a/autograder-core/src/test/java/de/firemage/autograder/core/check/api/TestSimplifyArraysFill.java b/autograder-core/src/test/java/de/firemage/autograder/core/check/api/TestSimplifyArraysFill.java index 737e9470..b07accea 100644 --- a/autograder-core/src/test/java/de/firemage/autograder/core/check/api/TestSimplifyArraysFill.java +++ b/autograder-core/src/test/java/de/firemage/autograder/core/check/api/TestSimplifyArraysFill.java @@ -1,11 +1,11 @@ package de.firemage.autograder.core.check.api; -import de.firemage.autograder.core.LinterException; +import de.firemage.autograder.api.LinterException; import de.firemage.autograder.core.LocalizedMessage; import de.firemage.autograder.core.Problem; import de.firemage.autograder.core.ProblemType; import de.firemage.autograder.core.check.AbstractCheckTest; -import de.firemage.autograder.core.compiler.JavaVersion; +import de.firemage.autograder.api.JavaVersion; import de.firemage.autograder.core.file.StringSourceInfo; import org.junit.jupiter.api.Test; diff --git a/autograder-core/src/test/java/de/firemage/autograder/core/check/api/TestStringRepeat.java b/autograder-core/src/test/java/de/firemage/autograder/core/check/api/TestStringRepeat.java index e294d5b0..79d9ca16 100644 --- a/autograder-core/src/test/java/de/firemage/autograder/core/check/api/TestStringRepeat.java +++ b/autograder-core/src/test/java/de/firemage/autograder/core/check/api/TestStringRepeat.java @@ -1,11 +1,11 @@ package de.firemage.autograder.core.check.api; -import de.firemage.autograder.core.LinterException; +import de.firemage.autograder.api.LinterException; import de.firemage.autograder.core.LocalizedMessage; import de.firemage.autograder.core.Problem; import de.firemage.autograder.core.ProblemType; import de.firemage.autograder.core.check.AbstractCheckTest; -import de.firemage.autograder.core.compiler.JavaVersion; +import de.firemage.autograder.api.JavaVersion; import de.firemage.autograder.core.file.StringSourceInfo; import org.junit.jupiter.api.Test; diff --git a/autograder-core/src/test/java/de/firemage/autograder/core/check/api/TestUseArrayCopy.java b/autograder-core/src/test/java/de/firemage/autograder/core/check/api/TestUseArrayCopy.java index f60ada61..75196170 100644 --- a/autograder-core/src/test/java/de/firemage/autograder/core/check/api/TestUseArrayCopy.java +++ b/autograder-core/src/test/java/de/firemage/autograder/core/check/api/TestUseArrayCopy.java @@ -1,11 +1,11 @@ package de.firemage.autograder.core.check.api; -import de.firemage.autograder.core.LinterException; +import de.firemage.autograder.api.LinterException; import de.firemage.autograder.core.LocalizedMessage; import de.firemage.autograder.core.Problem; import de.firemage.autograder.core.ProblemType; import de.firemage.autograder.core.check.AbstractCheckTest; -import de.firemage.autograder.core.compiler.JavaVersion; +import de.firemage.autograder.api.JavaVersion; import de.firemage.autograder.core.file.StringSourceInfo; import org.junit.jupiter.api.Test; diff --git a/autograder-core/src/test/java/de/firemage/autograder/core/check/api/TestUseArraysFill.java b/autograder-core/src/test/java/de/firemage/autograder/core/check/api/TestUseArraysFill.java index e8467b2d..de5f1d13 100644 --- a/autograder-core/src/test/java/de/firemage/autograder/core/check/api/TestUseArraysFill.java +++ b/autograder-core/src/test/java/de/firemage/autograder/core/check/api/TestUseArraysFill.java @@ -1,11 +1,11 @@ package de.firemage.autograder.core.check.api; -import de.firemage.autograder.core.LinterException; +import de.firemage.autograder.api.LinterException; import de.firemage.autograder.core.LocalizedMessage; import de.firemage.autograder.core.Problem; import de.firemage.autograder.core.ProblemType; import de.firemage.autograder.core.check.AbstractCheckTest; -import de.firemage.autograder.core.compiler.JavaVersion; +import de.firemage.autograder.api.JavaVersion; import de.firemage.autograder.core.file.StringSourceInfo; import org.junit.jupiter.api.Test; diff --git a/autograder-core/src/test/java/de/firemage/autograder/core/check/api/TestUseEnumValues.java b/autograder-core/src/test/java/de/firemage/autograder/core/check/api/TestUseEnumValues.java index 1c810d77..933e16fb 100644 --- a/autograder-core/src/test/java/de/firemage/autograder/core/check/api/TestUseEnumValues.java +++ b/autograder-core/src/test/java/de/firemage/autograder/core/check/api/TestUseEnumValues.java @@ -1,12 +1,12 @@ package de.firemage.autograder.core.check.api; -import de.firemage.autograder.core.LinterException; +import de.firemage.autograder.api.LinterException; import de.firemage.autograder.core.LocalizedMessage; import de.firemage.autograder.core.Problem; import de.firemage.autograder.core.ProblemType; import de.firemage.autograder.core.file.StringSourceInfo; import de.firemage.autograder.core.check.AbstractCheckTest; -import de.firemage.autograder.core.compiler.JavaVersion; +import de.firemage.autograder.api.JavaVersion; import org.junit.jupiter.api.Test; import java.io.IOException; diff --git a/autograder-core/src/test/java/de/firemage/autograder/core/check/api/TestUseFormatString.java b/autograder-core/src/test/java/de/firemage/autograder/core/check/api/TestUseFormatString.java index 711df45a..0a8e774b 100644 --- a/autograder-core/src/test/java/de/firemage/autograder/core/check/api/TestUseFormatString.java +++ b/autograder-core/src/test/java/de/firemage/autograder/core/check/api/TestUseFormatString.java @@ -1,12 +1,12 @@ package de.firemage.autograder.core.check.api; -import de.firemage.autograder.core.LinterException; +import de.firemage.autograder.api.LinterException; import de.firemage.autograder.core.LocalizedMessage; import de.firemage.autograder.core.Problem; import de.firemage.autograder.core.ProblemType; import de.firemage.autograder.core.file.StringSourceInfo; import de.firemage.autograder.core.check.AbstractCheckTest; -import de.firemage.autograder.core.compiler.JavaVersion; +import de.firemage.autograder.api.JavaVersion; import org.junit.jupiter.api.Test; import java.io.IOException; diff --git a/autograder-core/src/test/java/de/firemage/autograder/core/check/api/TestUseModuloOperator.java b/autograder-core/src/test/java/de/firemage/autograder/core/check/api/TestUseModuloOperator.java index 167854d6..4a7b57ea 100644 --- a/autograder-core/src/test/java/de/firemage/autograder/core/check/api/TestUseModuloOperator.java +++ b/autograder-core/src/test/java/de/firemage/autograder/core/check/api/TestUseModuloOperator.java @@ -1,11 +1,11 @@ package de.firemage.autograder.core.check.api; -import de.firemage.autograder.core.LinterException; +import de.firemage.autograder.api.LinterException; import de.firemage.autograder.core.LocalizedMessage; import de.firemage.autograder.core.Problem; import de.firemage.autograder.core.ProblemType; import de.firemage.autograder.core.check.AbstractCheckTest; -import de.firemage.autograder.core.compiler.JavaVersion; +import de.firemage.autograder.api.JavaVersion; import de.firemage.autograder.core.file.StringSourceInfo; import org.junit.jupiter.api.Test; diff --git a/autograder-core/src/test/java/de/firemage/autograder/core/check/api/TestUseStringFormatted.java b/autograder-core/src/test/java/de/firemage/autograder/core/check/api/TestUseStringFormatted.java index 995a029e..96db5b97 100644 --- a/autograder-core/src/test/java/de/firemage/autograder/core/check/api/TestUseStringFormatted.java +++ b/autograder-core/src/test/java/de/firemage/autograder/core/check/api/TestUseStringFormatted.java @@ -1,11 +1,11 @@ package de.firemage.autograder.core.check.api; -import de.firemage.autograder.core.LinterException; +import de.firemage.autograder.api.LinterException; import de.firemage.autograder.core.LocalizedMessage; import de.firemage.autograder.core.Problem; import de.firemage.autograder.core.ProblemType; import de.firemage.autograder.core.check.AbstractCheckTest; -import de.firemage.autograder.core.compiler.JavaVersion; +import de.firemage.autograder.api.JavaVersion; import de.firemage.autograder.core.file.StringSourceInfo; import org.junit.jupiter.api.Test; diff --git a/autograder-core/src/test/java/de/firemage/autograder/core/check/api/TestUseSubList.java b/autograder-core/src/test/java/de/firemage/autograder/core/check/api/TestUseSubList.java index 42ae61b4..05f9f995 100644 --- a/autograder-core/src/test/java/de/firemage/autograder/core/check/api/TestUseSubList.java +++ b/autograder-core/src/test/java/de/firemage/autograder/core/check/api/TestUseSubList.java @@ -1,11 +1,11 @@ package de.firemage.autograder.core.check.api; -import de.firemage.autograder.core.LinterException; +import de.firemage.autograder.api.LinterException; import de.firemage.autograder.core.LocalizedMessage; import de.firemage.autograder.core.Problem; import de.firemage.autograder.core.ProblemType; import de.firemage.autograder.core.check.AbstractCheckTest; -import de.firemage.autograder.core.compiler.JavaVersion; +import de.firemage.autograder.api.JavaVersion; import de.firemage.autograder.core.file.StringSourceInfo; import org.junit.jupiter.api.Test; diff --git a/autograder-core/src/test/java/de/firemage/autograder/core/check/comment/TestCommentedOutCodeCheck.java b/autograder-core/src/test/java/de/firemage/autograder/core/check/comment/TestCommentedOutCodeCheck.java index d370b8f7..4b39f0c3 100644 --- a/autograder-core/src/test/java/de/firemage/autograder/core/check/comment/TestCommentedOutCodeCheck.java +++ b/autograder-core/src/test/java/de/firemage/autograder/core/check/comment/TestCommentedOutCodeCheck.java @@ -1,11 +1,11 @@ package de.firemage.autograder.core.check.comment; -import de.firemage.autograder.core.LinterException; +import de.firemage.autograder.api.LinterException; import de.firemage.autograder.core.LocalizedMessage; import de.firemage.autograder.core.Problem; import de.firemage.autograder.core.ProblemType; import de.firemage.autograder.core.check.AbstractCheckTest; -import de.firemage.autograder.core.compiler.JavaVersion; +import de.firemage.autograder.api.JavaVersion; import de.firemage.autograder.core.file.StringSourceInfo; import org.junit.jupiter.api.Test; diff --git a/autograder-core/src/test/java/de/firemage/autograder/core/check/comment/TestFieldJavadocCheck.java b/autograder-core/src/test/java/de/firemage/autograder/core/check/comment/TestFieldJavadocCheck.java index 15843ae6..a28f5e38 100644 --- a/autograder-core/src/test/java/de/firemage/autograder/core/check/comment/TestFieldJavadocCheck.java +++ b/autograder-core/src/test/java/de/firemage/autograder/core/check/comment/TestFieldJavadocCheck.java @@ -1,11 +1,11 @@ package de.firemage.autograder.core.check.comment; -import de.firemage.autograder.core.LinterException; +import de.firemage.autograder.api.LinterException; import de.firemage.autograder.core.LocalizedMessage; import de.firemage.autograder.core.Problem; import de.firemage.autograder.core.ProblemType; import de.firemage.autograder.core.check.AbstractCheckTest; -import de.firemage.autograder.core.compiler.JavaVersion; +import de.firemage.autograder.api.JavaVersion; import de.firemage.autograder.core.file.SourceInfo; import de.firemage.autograder.core.file.StringSourceInfo; import org.junit.jupiter.params.ParameterizedTest; diff --git a/autograder-core/src/test/java/de/firemage/autograder/core/check/comment/TestMethodJavadocCheck.java b/autograder-core/src/test/java/de/firemage/autograder/core/check/comment/TestMethodJavadocCheck.java index acb81238..b74b1e59 100644 --- a/autograder-core/src/test/java/de/firemage/autograder/core/check/comment/TestMethodJavadocCheck.java +++ b/autograder-core/src/test/java/de/firemage/autograder/core/check/comment/TestMethodJavadocCheck.java @@ -1,11 +1,11 @@ package de.firemage.autograder.core.check.comment; -import de.firemage.autograder.core.LinterException; +import de.firemage.autograder.api.LinterException; import de.firemage.autograder.core.LocalizedMessage; import de.firemage.autograder.core.Problem; import de.firemage.autograder.core.ProblemType; import de.firemage.autograder.core.check.AbstractCheckTest; -import de.firemage.autograder.core.compiler.JavaVersion; +import de.firemage.autograder.api.JavaVersion; import de.firemage.autograder.core.file.SourceInfo; import de.firemage.autograder.core.file.StringSourceInfo; import org.junit.jupiter.params.ParameterizedTest; diff --git a/autograder-core/src/test/java/de/firemage/autograder/core/check/comment/TestUnnecessaryComment.java b/autograder-core/src/test/java/de/firemage/autograder/core/check/comment/TestUnnecessaryComment.java index 1bffab33..1d5bd418 100644 --- a/autograder-core/src/test/java/de/firemage/autograder/core/check/comment/TestUnnecessaryComment.java +++ b/autograder-core/src/test/java/de/firemage/autograder/core/check/comment/TestUnnecessaryComment.java @@ -1,11 +1,11 @@ package de.firemage.autograder.core.check.comment; -import de.firemage.autograder.core.LinterException; +import de.firemage.autograder.api.LinterException; import de.firemage.autograder.core.LocalizedMessage; import de.firemage.autograder.core.Problem; import de.firemage.autograder.core.ProblemType; import de.firemage.autograder.core.check.AbstractCheckTest; -import de.firemage.autograder.core.compiler.JavaVersion; +import de.firemage.autograder.api.JavaVersion; import de.firemage.autograder.core.file.StringSourceInfo; import org.junit.jupiter.api.Test; diff --git a/autograder-core/src/test/java/de/firemage/autograder/core/check/complexity/TestExtendsObjectCheck.java b/autograder-core/src/test/java/de/firemage/autograder/core/check/complexity/TestExtendsObjectCheck.java index 6812ebd8..3bcbec57 100644 --- a/autograder-core/src/test/java/de/firemage/autograder/core/check/complexity/TestExtendsObjectCheck.java +++ b/autograder-core/src/test/java/de/firemage/autograder/core/check/complexity/TestExtendsObjectCheck.java @@ -1,11 +1,11 @@ package de.firemage.autograder.core.check.complexity; -import de.firemage.autograder.core.LinterException; -import de.firemage.autograder.core.Problem; +import de.firemage.autograder.api.JavaVersion; +import de.firemage.autograder.api.LinterException; import de.firemage.autograder.core.ProblemType; -import de.firemage.autograder.core.file.StringSourceInfo; +import de.firemage.autograder.core.Problem; import de.firemage.autograder.core.check.AbstractCheckTest; -import de.firemage.autograder.core.compiler.JavaVersion; +import de.firemage.autograder.core.file.StringSourceInfo; import org.junit.jupiter.api.Test; import java.io.IOException; diff --git a/autograder-core/src/test/java/de/firemage/autograder/core/check/complexity/TestRedundantAssignment.java b/autograder-core/src/test/java/de/firemage/autograder/core/check/complexity/TestRedundantAssignment.java index 41210ee6..5063e156 100644 --- a/autograder-core/src/test/java/de/firemage/autograder/core/check/complexity/TestRedundantAssignment.java +++ b/autograder-core/src/test/java/de/firemage/autograder/core/check/complexity/TestRedundantAssignment.java @@ -1,11 +1,11 @@ package de.firemage.autograder.core.check.complexity; -import de.firemage.autograder.core.LinterException; +import de.firemage.autograder.api.LinterException; import de.firemage.autograder.core.LocalizedMessage; import de.firemage.autograder.core.Problem; import de.firemage.autograder.core.ProblemType; import de.firemage.autograder.core.check.AbstractCheckTest; -import de.firemage.autograder.core.compiler.JavaVersion; +import de.firemage.autograder.api.JavaVersion; import de.firemage.autograder.core.file.StringSourceInfo; import org.junit.jupiter.api.Test; diff --git a/autograder-core/src/test/java/de/firemage/autograder/core/check/complexity/TestRedundantConstructor.java b/autograder-core/src/test/java/de/firemage/autograder/core/check/complexity/TestRedundantConstructor.java index 2ad3627a..864788a0 100644 --- a/autograder-core/src/test/java/de/firemage/autograder/core/check/complexity/TestRedundantConstructor.java +++ b/autograder-core/src/test/java/de/firemage/autograder/core/check/complexity/TestRedundantConstructor.java @@ -1,11 +1,11 @@ package de.firemage.autograder.core.check.complexity; -import de.firemage.autograder.core.LinterException; +import de.firemage.autograder.api.LinterException; import de.firemage.autograder.core.LocalizedMessage; import de.firemage.autograder.core.Problem; import de.firemage.autograder.core.ProblemType; import de.firemage.autograder.core.check.AbstractCheckTest; -import de.firemage.autograder.core.compiler.JavaVersion; +import de.firemage.autograder.api.JavaVersion; import de.firemage.autograder.core.file.SourceInfo; import de.firemage.autograder.core.file.StringSourceInfo; import org.junit.jupiter.api.Test; diff --git a/autograder-core/src/test/java/de/firemage/autograder/core/check/complexity/TestRedundantElse.java b/autograder-core/src/test/java/de/firemage/autograder/core/check/complexity/TestRedundantElse.java index e3a27f37..ea9d0e60 100644 --- a/autograder-core/src/test/java/de/firemage/autograder/core/check/complexity/TestRedundantElse.java +++ b/autograder-core/src/test/java/de/firemage/autograder/core/check/complexity/TestRedundantElse.java @@ -1,18 +1,15 @@ package de.firemage.autograder.core.check.complexity; -import de.firemage.autograder.core.LinterException; +import de.firemage.autograder.api.LinterException; import de.firemage.autograder.core.LocalizedMessage; import de.firemage.autograder.core.Problem; import de.firemage.autograder.core.ProblemType; import de.firemage.autograder.core.check.AbstractCheckTest; -import de.firemage.autograder.core.compiler.JavaVersion; +import de.firemage.autograder.api.JavaVersion; import de.firemage.autograder.core.file.StringSourceInfo; -import org.junit.jupiter.api.Disabled; import org.junit.jupiter.api.Test; -import org.junit.jupiter.api.io.TempDir; import java.io.IOException; -import java.nio.file.Path; import java.util.List; import java.util.Map; diff --git a/autograder-core/src/test/java/de/firemage/autograder/core/check/complexity/TestRedundantIfForBooleanCheck.java b/autograder-core/src/test/java/de/firemage/autograder/core/check/complexity/TestRedundantIfForBooleanCheck.java index 46642ba7..792dadab 100644 --- a/autograder-core/src/test/java/de/firemage/autograder/core/check/complexity/TestRedundantIfForBooleanCheck.java +++ b/autograder-core/src/test/java/de/firemage/autograder/core/check/complexity/TestRedundantIfForBooleanCheck.java @@ -1,11 +1,11 @@ package de.firemage.autograder.core.check.complexity; -import de.firemage.autograder.core.LinterException; +import de.firemage.autograder.api.LinterException; import de.firemage.autograder.core.LocalizedMessage; import de.firemage.autograder.core.Problem; import de.firemage.autograder.core.ProblemType; import de.firemage.autograder.core.check.AbstractCheckTest; -import de.firemage.autograder.core.compiler.JavaVersion; +import de.firemage.autograder.api.JavaVersion; import de.firemage.autograder.core.file.StringSourceInfo; import org.junit.jupiter.api.Test; diff --git a/autograder-core/src/test/java/de/firemage/autograder/core/check/complexity/TestRedundantModifier.java b/autograder-core/src/test/java/de/firemage/autograder/core/check/complexity/TestRedundantModifier.java index 84282892..af82f693 100644 --- a/autograder-core/src/test/java/de/firemage/autograder/core/check/complexity/TestRedundantModifier.java +++ b/autograder-core/src/test/java/de/firemage/autograder/core/check/complexity/TestRedundantModifier.java @@ -1,11 +1,11 @@ package de.firemage.autograder.core.check.complexity; -import de.firemage.autograder.core.LinterException; +import de.firemage.autograder.api.LinterException; import de.firemage.autograder.core.LocalizedMessage; import de.firemage.autograder.core.Problem; import de.firemage.autograder.core.ProblemType; import de.firemage.autograder.core.check.AbstractCheckTest; -import de.firemage.autograder.core.compiler.JavaVersion; +import de.firemage.autograder.api.JavaVersion; import de.firemage.autograder.core.file.StringSourceInfo; import org.junit.jupiter.api.Test; diff --git a/autograder-core/src/test/java/de/firemage/autograder/core/check/complexity/TestRedundantNegationCheck.java b/autograder-core/src/test/java/de/firemage/autograder/core/check/complexity/TestRedundantNegationCheck.java index 59fcb6e5..baab8ee5 100644 --- a/autograder-core/src/test/java/de/firemage/autograder/core/check/complexity/TestRedundantNegationCheck.java +++ b/autograder-core/src/test/java/de/firemage/autograder/core/check/complexity/TestRedundantNegationCheck.java @@ -1,11 +1,11 @@ package de.firemage.autograder.core.check.complexity; -import de.firemage.autograder.core.LinterException; +import de.firemage.autograder.api.LinterException; import de.firemage.autograder.core.LocalizedMessage; import de.firemage.autograder.core.Problem; import de.firemage.autograder.core.ProblemType; import de.firemage.autograder.core.check.AbstractCheckTest; -import de.firemage.autograder.core.compiler.JavaVersion; +import de.firemage.autograder.api.JavaVersion; import de.firemage.autograder.core.file.StringSourceInfo; import org.junit.jupiter.api.Test; import org.junit.jupiter.params.ParameterizedTest; diff --git a/autograder-core/src/test/java/de/firemage/autograder/core/check/complexity/TestRedundantUninitializedVariable.java b/autograder-core/src/test/java/de/firemage/autograder/core/check/complexity/TestRedundantUninitializedVariable.java index 8dabc6db..0b994d83 100644 --- a/autograder-core/src/test/java/de/firemage/autograder/core/check/complexity/TestRedundantUninitializedVariable.java +++ b/autograder-core/src/test/java/de/firemage/autograder/core/check/complexity/TestRedundantUninitializedVariable.java @@ -1,12 +1,12 @@ package de.firemage.autograder.core.check.complexity; -import de.firemage.autograder.core.LinterException; +import de.firemage.autograder.api.LinterException; import de.firemage.autograder.core.LocalizedMessage; -import de.firemage.autograder.core.Problem; import de.firemage.autograder.core.ProblemType; +import de.firemage.autograder.core.Problem; import de.firemage.autograder.core.file.StringSourceInfo; import de.firemage.autograder.core.check.AbstractCheckTest; -import de.firemage.autograder.core.compiler.JavaVersion; +import de.firemage.autograder.api.JavaVersion; import org.junit.jupiter.api.Test; import java.io.IOException; diff --git a/autograder-core/src/test/java/de/firemage/autograder/core/check/complexity/TestRedundantVariable.java b/autograder-core/src/test/java/de/firemage/autograder/core/check/complexity/TestRedundantVariable.java index b5f3c0b9..bae8155b 100644 --- a/autograder-core/src/test/java/de/firemage/autograder/core/check/complexity/TestRedundantVariable.java +++ b/autograder-core/src/test/java/de/firemage/autograder/core/check/complexity/TestRedundantVariable.java @@ -1,11 +1,11 @@ package de.firemage.autograder.core.check.complexity; -import de.firemage.autograder.core.LinterException; +import de.firemage.autograder.api.LinterException; import de.firemage.autograder.core.LocalizedMessage; import de.firemage.autograder.core.Problem; import de.firemage.autograder.core.ProblemType; import de.firemage.autograder.core.check.AbstractCheckTest; -import de.firemage.autograder.core.compiler.JavaVersion; +import de.firemage.autograder.api.JavaVersion; import de.firemage.autograder.core.file.StringSourceInfo; import org.junit.jupiter.api.Test; diff --git a/autograder-core/src/test/java/de/firemage/autograder/core/check/complexity/TestRepeatedMathOperationCheck.java b/autograder-core/src/test/java/de/firemage/autograder/core/check/complexity/TestRepeatedMathOperationCheck.java index 2d00521a..07682c8a 100644 --- a/autograder-core/src/test/java/de/firemage/autograder/core/check/complexity/TestRepeatedMathOperationCheck.java +++ b/autograder-core/src/test/java/de/firemage/autograder/core/check/complexity/TestRepeatedMathOperationCheck.java @@ -1,11 +1,11 @@ package de.firemage.autograder.core.check.complexity; -import de.firemage.autograder.core.LinterException; +import de.firemage.autograder.api.LinterException; import de.firemage.autograder.core.LocalizedMessage; import de.firemage.autograder.core.Problem; import de.firemage.autograder.core.ProblemType; import de.firemage.autograder.core.check.AbstractCheckTest; -import de.firemage.autograder.core.compiler.JavaVersion; +import de.firemage.autograder.api.JavaVersion; import de.firemage.autograder.core.file.StringSourceInfo; import org.junit.jupiter.api.Test; diff --git a/autograder-core/src/test/java/de/firemage/autograder/core/check/complexity/TestTooManyExceptions.java b/autograder-core/src/test/java/de/firemage/autograder/core/check/complexity/TestTooManyExceptions.java index 0eb33df2..88496694 100644 --- a/autograder-core/src/test/java/de/firemage/autograder/core/check/complexity/TestTooManyExceptions.java +++ b/autograder-core/src/test/java/de/firemage/autograder/core/check/complexity/TestTooManyExceptions.java @@ -1,11 +1,11 @@ package de.firemage.autograder.core.check.complexity; -import de.firemage.autograder.core.LinterException; +import de.firemage.autograder.api.LinterException; import de.firemage.autograder.core.LocalizedMessage; import de.firemage.autograder.core.Problem; import de.firemage.autograder.core.ProblemType; import de.firemage.autograder.core.check.AbstractCheckTest; -import de.firemage.autograder.core.compiler.JavaVersion; +import de.firemage.autograder.api.JavaVersion; import de.firemage.autograder.core.file.StringSourceInfo; import org.junit.jupiter.api.Test; diff --git a/autograder-core/src/test/java/de/firemage/autograder/core/check/complexity/TestTryCatchComplexity.java b/autograder-core/src/test/java/de/firemage/autograder/core/check/complexity/TestTryCatchComplexity.java index 46aa96f5..2c41002c 100644 --- a/autograder-core/src/test/java/de/firemage/autograder/core/check/complexity/TestTryCatchComplexity.java +++ b/autograder-core/src/test/java/de/firemage/autograder/core/check/complexity/TestTryCatchComplexity.java @@ -1,11 +1,11 @@ package de.firemage.autograder.core.check.complexity; -import de.firemage.autograder.core.LinterException; +import de.firemage.autograder.api.LinterException; import de.firemage.autograder.core.LocalizedMessage; import de.firemage.autograder.core.Problem; import de.firemage.autograder.core.ProblemType; import de.firemage.autograder.core.check.AbstractCheckTest; -import de.firemage.autograder.core.compiler.JavaVersion; +import de.firemage.autograder.api.JavaVersion; import de.firemage.autograder.core.file.StringSourceInfo; import org.junit.jupiter.api.Test; diff --git a/autograder-core/src/test/java/de/firemage/autograder/core/check/complexity/TestUnnecessaryBoxing.java b/autograder-core/src/test/java/de/firemage/autograder/core/check/complexity/TestUnnecessaryBoxing.java index cd4520f8..df01a277 100644 --- a/autograder-core/src/test/java/de/firemage/autograder/core/check/complexity/TestUnnecessaryBoxing.java +++ b/autograder-core/src/test/java/de/firemage/autograder/core/check/complexity/TestUnnecessaryBoxing.java @@ -1,11 +1,11 @@ package de.firemage.autograder.core.check.complexity; -import de.firemage.autograder.core.LinterException; +import de.firemage.autograder.api.LinterException; import de.firemage.autograder.core.LocalizedMessage; import de.firemage.autograder.core.Problem; import de.firemage.autograder.core.ProblemType; import de.firemage.autograder.core.check.AbstractCheckTest; -import de.firemage.autograder.core.compiler.JavaVersion; +import de.firemage.autograder.api.JavaVersion; import de.firemage.autograder.core.file.StringSourceInfo; import org.junit.jupiter.api.Test; diff --git a/autograder-core/src/test/java/de/firemage/autograder/core/check/complexity/TestUnusedImport.java b/autograder-core/src/test/java/de/firemage/autograder/core/check/complexity/TestUnusedImport.java index 4156ee61..72e8ce09 100644 --- a/autograder-core/src/test/java/de/firemage/autograder/core/check/complexity/TestUnusedImport.java +++ b/autograder-core/src/test/java/de/firemage/autograder/core/check/complexity/TestUnusedImport.java @@ -1,11 +1,11 @@ package de.firemage.autograder.core.check.complexity; -import de.firemage.autograder.core.LinterException; +import de.firemage.autograder.api.LinterException; import de.firemage.autograder.core.LocalizedMessage; import de.firemage.autograder.core.Problem; import de.firemage.autograder.core.ProblemType; import de.firemage.autograder.core.check.AbstractCheckTest; -import de.firemage.autograder.core.compiler.JavaVersion; +import de.firemage.autograder.api.JavaVersion; import de.firemage.autograder.core.file.StringSourceInfo; import org.junit.jupiter.api.Disabled; import org.junit.jupiter.api.Test; diff --git a/autograder-core/src/test/java/de/firemage/autograder/core/check/complexity/TestWrapperInstantiationCheck.java b/autograder-core/src/test/java/de/firemage/autograder/core/check/complexity/TestWrapperInstantiationCheck.java index 0f60ca57..22e3cba3 100644 --- a/autograder-core/src/test/java/de/firemage/autograder/core/check/complexity/TestWrapperInstantiationCheck.java +++ b/autograder-core/src/test/java/de/firemage/autograder/core/check/complexity/TestWrapperInstantiationCheck.java @@ -1,11 +1,11 @@ package de.firemage.autograder.core.check.complexity; -import de.firemage.autograder.core.LinterException; +import de.firemage.autograder.api.LinterException; import de.firemage.autograder.core.LocalizedMessage; import de.firemage.autograder.core.Problem; import de.firemage.autograder.core.ProblemType; import de.firemage.autograder.core.check.AbstractCheckTest; -import de.firemage.autograder.core.compiler.JavaVersion; +import de.firemage.autograder.api.JavaVersion; import de.firemage.autograder.core.file.StringSourceInfo; import org.junit.jupiter.api.Test; import org.junit.jupiter.params.ParameterizedTest; diff --git a/autograder-core/src/test/java/de/firemage/autograder/core/check/exceptions/TestCustomExceptionInheritanceCheck.java b/autograder-core/src/test/java/de/firemage/autograder/core/check/exceptions/TestCustomExceptionInheritanceCheck.java index 24032cb6..c52bcabd 100644 --- a/autograder-core/src/test/java/de/firemage/autograder/core/check/exceptions/TestCustomExceptionInheritanceCheck.java +++ b/autograder-core/src/test/java/de/firemage/autograder/core/check/exceptions/TestCustomExceptionInheritanceCheck.java @@ -1,11 +1,11 @@ package de.firemage.autograder.core.check.exceptions; -import de.firemage.autograder.core.LinterException; +import de.firemage.autograder.api.LinterException; import de.firemage.autograder.core.LocalizedMessage; import de.firemage.autograder.core.Problem; import de.firemage.autograder.core.ProblemType; import de.firemage.autograder.core.check.AbstractCheckTest; -import de.firemage.autograder.core.compiler.JavaVersion; +import de.firemage.autograder.api.JavaVersion; import de.firemage.autograder.core.file.StringSourceInfo; import org.junit.jupiter.api.Test; diff --git a/autograder-core/src/test/java/de/firemage/autograder/core/check/exceptions/TestExceptionMessageCheck.java b/autograder-core/src/test/java/de/firemage/autograder/core/check/exceptions/TestExceptionMessageCheck.java index 4790f1ec..fda483ea 100644 --- a/autograder-core/src/test/java/de/firemage/autograder/core/check/exceptions/TestExceptionMessageCheck.java +++ b/autograder-core/src/test/java/de/firemage/autograder/core/check/exceptions/TestExceptionMessageCheck.java @@ -1,11 +1,11 @@ package de.firemage.autograder.core.check.exceptions; -import de.firemage.autograder.core.LinterException; +import de.firemage.autograder.api.LinterException; import de.firemage.autograder.core.LocalizedMessage; import de.firemage.autograder.core.Problem; import de.firemage.autograder.core.ProblemType; import de.firemage.autograder.core.check.AbstractCheckTest; -import de.firemage.autograder.core.compiler.JavaVersion; +import de.firemage.autograder.api.JavaVersion; import de.firemage.autograder.core.file.StringSourceInfo; import org.junit.jupiter.api.Test; diff --git a/autograder-core/src/test/java/de/firemage/autograder/core/check/exceptions/TestNumberFormatExceptionIgnored.java b/autograder-core/src/test/java/de/firemage/autograder/core/check/exceptions/TestNumberFormatExceptionIgnored.java index 22302c6b..43547e27 100644 --- a/autograder-core/src/test/java/de/firemage/autograder/core/check/exceptions/TestNumberFormatExceptionIgnored.java +++ b/autograder-core/src/test/java/de/firemage/autograder/core/check/exceptions/TestNumberFormatExceptionIgnored.java @@ -1,11 +1,11 @@ package de.firemage.autograder.core.check.exceptions; -import de.firemage.autograder.core.LinterException; +import de.firemage.autograder.api.LinterException; import de.firemage.autograder.core.LocalizedMessage; import de.firemage.autograder.core.Problem; import de.firemage.autograder.core.ProblemType; import de.firemage.autograder.core.check.AbstractCheckTest; -import de.firemage.autograder.core.compiler.JavaVersion; +import de.firemage.autograder.api.JavaVersion; import de.firemage.autograder.core.file.StringSourceInfo; import org.junit.jupiter.api.Test; diff --git a/autograder-core/src/test/java/de/firemage/autograder/core/check/general/TestAvoidShadowing.java b/autograder-core/src/test/java/de/firemage/autograder/core/check/general/TestAvoidShadowing.java index e611d4b9..2f4ecf2b 100644 --- a/autograder-core/src/test/java/de/firemage/autograder/core/check/general/TestAvoidShadowing.java +++ b/autograder-core/src/test/java/de/firemage/autograder/core/check/general/TestAvoidShadowing.java @@ -1,11 +1,11 @@ package de.firemage.autograder.core.check.general; -import de.firemage.autograder.core.LinterException; +import de.firemage.autograder.api.LinterException; import de.firemage.autograder.core.LocalizedMessage; import de.firemage.autograder.core.Problem; import de.firemage.autograder.core.ProblemType; import de.firemage.autograder.core.check.AbstractCheckTest; -import de.firemage.autograder.core.compiler.JavaVersion; +import de.firemage.autograder.api.JavaVersion; import de.firemage.autograder.core.file.StringSourceInfo; import org.junit.jupiter.api.Test; diff --git a/autograder-core/src/test/java/de/firemage/autograder/core/check/general/TestCompareCharValue.java b/autograder-core/src/test/java/de/firemage/autograder/core/check/general/TestCompareCharValue.java index 03cc0bf3..6de6729b 100644 --- a/autograder-core/src/test/java/de/firemage/autograder/core/check/general/TestCompareCharValue.java +++ b/autograder-core/src/test/java/de/firemage/autograder/core/check/general/TestCompareCharValue.java @@ -1,11 +1,11 @@ package de.firemage.autograder.core.check.general; -import de.firemage.autograder.core.LinterException; +import de.firemage.autograder.api.LinterException; import de.firemage.autograder.core.LocalizedMessage; import de.firemage.autograder.core.Problem; import de.firemage.autograder.core.ProblemType; import de.firemage.autograder.core.check.AbstractCheckTest; -import de.firemage.autograder.core.compiler.JavaVersion; +import de.firemage.autograder.api.JavaVersion; import de.firemage.autograder.core.file.StringSourceInfo; import org.junit.jupiter.api.Test; diff --git a/autograder-core/src/test/java/de/firemage/autograder/core/check/general/TestFieldShouldBeFinal.java b/autograder-core/src/test/java/de/firemage/autograder/core/check/general/TestFieldShouldBeFinal.java index b8e0a23b..ad3846a6 100644 --- a/autograder-core/src/test/java/de/firemage/autograder/core/check/general/TestFieldShouldBeFinal.java +++ b/autograder-core/src/test/java/de/firemage/autograder/core/check/general/TestFieldShouldBeFinal.java @@ -1,16 +1,14 @@ package de.firemage.autograder.core.check.general; -import de.firemage.autograder.core.LinterException; +import de.firemage.autograder.api.LinterException; import de.firemage.autograder.core.LocalizedMessage; import de.firemage.autograder.core.Problem; import de.firemage.autograder.core.ProblemType; import de.firemage.autograder.core.check.AbstractCheckTest; -import de.firemage.autograder.core.compiler.JavaVersion; +import de.firemage.autograder.api.JavaVersion; import de.firemage.autograder.core.file.StringSourceInfo; import org.junit.jupiter.api.Disabled; import org.junit.jupiter.api.Test; -import org.junit.jupiter.params.ParameterizedTest; -import org.junit.jupiter.params.provider.CsvSource; import java.io.IOException; import java.util.List; diff --git a/autograder-core/src/test/java/de/firemage/autograder/core/check/general/TestForToForEachLoop.java b/autograder-core/src/test/java/de/firemage/autograder/core/check/general/TestForToForEachLoop.java index f5483312..e0fbb443 100644 --- a/autograder-core/src/test/java/de/firemage/autograder/core/check/general/TestForToForEachLoop.java +++ b/autograder-core/src/test/java/de/firemage/autograder/core/check/general/TestForToForEachLoop.java @@ -1,11 +1,11 @@ package de.firemage.autograder.core.check.general; -import de.firemage.autograder.core.LinterException; +import de.firemage.autograder.api.LinterException; import de.firemage.autograder.core.LocalizedMessage; import de.firemage.autograder.core.Problem; import de.firemage.autograder.core.ProblemType; import de.firemage.autograder.core.check.AbstractCheckTest; -import de.firemage.autograder.core.compiler.JavaVersion; +import de.firemage.autograder.api.JavaVersion; import de.firemage.autograder.core.file.StringSourceInfo; import org.junit.jupiter.api.Test; diff --git a/autograder-core/src/test/java/de/firemage/autograder/core/check/general/TestImportTypes.java b/autograder-core/src/test/java/de/firemage/autograder/core/check/general/TestImportTypes.java index c87f00cb..411c7570 100644 --- a/autograder-core/src/test/java/de/firemage/autograder/core/check/general/TestImportTypes.java +++ b/autograder-core/src/test/java/de/firemage/autograder/core/check/general/TestImportTypes.java @@ -1,11 +1,11 @@ package de.firemage.autograder.core.check.general; -import de.firemage.autograder.core.LinterException; +import de.firemage.autograder.api.LinterException; import de.firemage.autograder.core.LocalizedMessage; import de.firemage.autograder.core.Problem; import de.firemage.autograder.core.ProblemType; import de.firemage.autograder.core.check.AbstractCheckTest; -import de.firemage.autograder.core.compiler.JavaVersion; +import de.firemage.autograder.api.JavaVersion; import de.firemage.autograder.core.file.StringSourceInfo; import org.junit.jupiter.api.Test; diff --git a/autograder-core/src/test/java/de/firemage/autograder/core/check/general/TestLoopShouldBeDoWhile.java b/autograder-core/src/test/java/de/firemage/autograder/core/check/general/TestLoopShouldBeDoWhile.java index 7ba1820d..586d42c1 100644 --- a/autograder-core/src/test/java/de/firemage/autograder/core/check/general/TestLoopShouldBeDoWhile.java +++ b/autograder-core/src/test/java/de/firemage/autograder/core/check/general/TestLoopShouldBeDoWhile.java @@ -1,11 +1,11 @@ package de.firemage.autograder.core.check.general; -import de.firemage.autograder.core.LinterException; +import de.firemage.autograder.api.LinterException; import de.firemage.autograder.core.LocalizedMessage; import de.firemage.autograder.core.Problem; import de.firemage.autograder.core.ProblemType; import de.firemage.autograder.core.check.AbstractCheckTest; -import de.firemage.autograder.core.compiler.JavaVersion; +import de.firemage.autograder.api.JavaVersion; import de.firemage.autograder.core.file.StringSourceInfo; import org.junit.jupiter.api.Test; diff --git a/autograder-core/src/test/java/de/firemage/autograder/core/check/general/TestLoopShouldBeFor.java b/autograder-core/src/test/java/de/firemage/autograder/core/check/general/TestLoopShouldBeFor.java index 4d0eace6..7473a2da 100644 --- a/autograder-core/src/test/java/de/firemage/autograder/core/check/general/TestLoopShouldBeFor.java +++ b/autograder-core/src/test/java/de/firemage/autograder/core/check/general/TestLoopShouldBeFor.java @@ -1,11 +1,11 @@ package de.firemage.autograder.core.check.general; -import de.firemage.autograder.core.LinterException; +import de.firemage.autograder.api.LinterException; import de.firemage.autograder.core.LocalizedMessage; import de.firemage.autograder.core.Problem; import de.firemage.autograder.core.ProblemType; import de.firemage.autograder.core.check.AbstractCheckTest; -import de.firemage.autograder.core.compiler.JavaVersion; +import de.firemage.autograder.api.JavaVersion; import de.firemage.autograder.core.file.StringSourceInfo; import org.junit.jupiter.api.Test; import org.junit.jupiter.params.ParameterizedTest; diff --git a/autograder-core/src/test/java/de/firemage/autograder/core/check/general/TestMagicString.java b/autograder-core/src/test/java/de/firemage/autograder/core/check/general/TestMagicString.java index e83275e3..bb9575a7 100644 --- a/autograder-core/src/test/java/de/firemage/autograder/core/check/general/TestMagicString.java +++ b/autograder-core/src/test/java/de/firemage/autograder/core/check/general/TestMagicString.java @@ -1,11 +1,11 @@ package de.firemage.autograder.core.check.general; -import de.firemage.autograder.core.LinterException; +import de.firemage.autograder.api.LinterException; import de.firemage.autograder.core.LocalizedMessage; import de.firemage.autograder.core.Problem; import de.firemage.autograder.core.ProblemType; import de.firemage.autograder.core.check.AbstractCheckTest; -import de.firemage.autograder.core.compiler.JavaVersion; +import de.firemage.autograder.api.JavaVersion; import de.firemage.autograder.core.file.StringSourceInfo; import org.junit.jupiter.api.Test; diff --git a/autograder-core/src/test/java/de/firemage/autograder/core/check/general/TestObjectDatatype.java b/autograder-core/src/test/java/de/firemage/autograder/core/check/general/TestObjectDatatype.java index 17d25330..87d3b413 100644 --- a/autograder-core/src/test/java/de/firemage/autograder/core/check/general/TestObjectDatatype.java +++ b/autograder-core/src/test/java/de/firemage/autograder/core/check/general/TestObjectDatatype.java @@ -1,11 +1,11 @@ package de.firemage.autograder.core.check.general; -import de.firemage.autograder.core.LinterException; +import de.firemage.autograder.api.LinterException; import de.firemage.autograder.core.LocalizedMessage; import de.firemage.autograder.core.Problem; import de.firemage.autograder.core.ProblemType; import de.firemage.autograder.core.check.AbstractCheckTest; -import de.firemage.autograder.core.compiler.JavaVersion; +import de.firemage.autograder.api.JavaVersion; import de.firemage.autograder.core.file.StringSourceInfo; import org.junit.jupiter.api.Test; diff --git a/autograder-core/src/test/java/de/firemage/autograder/core/check/general/TestOverrideAnnotationMissing.java b/autograder-core/src/test/java/de/firemage/autograder/core/check/general/TestOverrideAnnotationMissing.java index 62ca6e0f..07fc54bb 100644 --- a/autograder-core/src/test/java/de/firemage/autograder/core/check/general/TestOverrideAnnotationMissing.java +++ b/autograder-core/src/test/java/de/firemage/autograder/core/check/general/TestOverrideAnnotationMissing.java @@ -1,11 +1,11 @@ package de.firemage.autograder.core.check.general; -import de.firemage.autograder.core.LinterException; +import de.firemage.autograder.api.LinterException; import de.firemage.autograder.core.LocalizedMessage; import de.firemage.autograder.core.Problem; import de.firemage.autograder.core.ProblemType; import de.firemage.autograder.core.check.AbstractCheckTest; -import de.firemage.autograder.core.compiler.JavaVersion; +import de.firemage.autograder.api.JavaVersion; import de.firemage.autograder.core.file.StringSourceInfo; import org.junit.jupiter.api.Test; diff --git a/autograder-core/src/test/java/de/firemage/autograder/core/check/general/TestReassignedParameterCheck.java b/autograder-core/src/test/java/de/firemage/autograder/core/check/general/TestReassignedParameterCheck.java index cc6e4ff0..0294d057 100644 --- a/autograder-core/src/test/java/de/firemage/autograder/core/check/general/TestReassignedParameterCheck.java +++ b/autograder-core/src/test/java/de/firemage/autograder/core/check/general/TestReassignedParameterCheck.java @@ -1,11 +1,11 @@ package de.firemage.autograder.core.check.general; -import de.firemage.autograder.core.LinterException; +import de.firemage.autograder.api.LinterException; import de.firemage.autograder.core.LocalizedMessage; import de.firemage.autograder.core.Problem; import de.firemage.autograder.core.ProblemType; import de.firemage.autograder.core.check.AbstractCheckTest; -import de.firemage.autograder.core.compiler.JavaVersion; +import de.firemage.autograder.api.JavaVersion; import de.firemage.autograder.core.file.StringSourceInfo; import org.junit.jupiter.api.Test; diff --git a/autograder-core/src/test/java/de/firemage/autograder/core/check/general/TestUseDifferentVisibility.java b/autograder-core/src/test/java/de/firemage/autograder/core/check/general/TestUseDifferentVisibility.java index 0dbaef3f..56629e2e 100644 --- a/autograder-core/src/test/java/de/firemage/autograder/core/check/general/TestUseDifferentVisibility.java +++ b/autograder-core/src/test/java/de/firemage/autograder/core/check/general/TestUseDifferentVisibility.java @@ -1,12 +1,12 @@ package de.firemage.autograder.core.check.general; -import de.firemage.autograder.core.LinterException; +import de.firemage.autograder.api.LinterException; import de.firemage.autograder.core.LocalizedMessage; import de.firemage.autograder.core.Problem; import de.firemage.autograder.core.ProblemType; import de.firemage.autograder.core.file.StringSourceInfo; import de.firemage.autograder.core.check.AbstractCheckTest; -import de.firemage.autograder.core.compiler.JavaVersion; +import de.firemage.autograder.api.JavaVersion; import org.junit.jupiter.api.Test; import java.io.IOException; diff --git a/autograder-core/src/test/java/de/firemage/autograder/core/check/naming/TestPackageNamingConvention.java b/autograder-core/src/test/java/de/firemage/autograder/core/check/naming/TestPackageNamingConvention.java index 8a868d43..39511c38 100644 --- a/autograder-core/src/test/java/de/firemage/autograder/core/check/naming/TestPackageNamingConvention.java +++ b/autograder-core/src/test/java/de/firemage/autograder/core/check/naming/TestPackageNamingConvention.java @@ -1,12 +1,11 @@ package de.firemage.autograder.core.check.naming; -import de.firemage.autograder.core.LinterException; +import de.firemage.autograder.api.LinterException; import de.firemage.autograder.core.LocalizedMessage; -import de.firemage.autograder.core.Problem; import de.firemage.autograder.core.ProblemType; import de.firemage.autograder.core.file.StringSourceInfo; import de.firemage.autograder.core.check.AbstractCheckTest; -import de.firemage.autograder.core.compiler.JavaVersion; +import de.firemage.autograder.api.JavaVersion; import org.junit.jupiter.api.Test; import java.io.IOException; @@ -21,7 +20,7 @@ class TestPackageNamingConvention extends AbstractCheckTest { @Test void testDefaultPackage() throws IOException, LinterException { - List problems = super.check(StringSourceInfo.fromSourceString( + var problems = super.check(StringSourceInfo.fromSourceString( JavaVersion.JAVA_17, "Test", "public class Test {}" @@ -33,7 +32,7 @@ void testDefaultPackage() throws IOException, LinterException { @Test void testSingleViolation() throws IOException, LinterException { - List problems = super.check(StringSourceInfo.fromSourceString( + var problems = super.check(StringSourceInfo.fromSourceString( JavaVersion.JAVA_17, "com.Example.Test", """ @@ -54,7 +53,7 @@ public class Test {} @Test void testMultipleViolations() throws IOException, LinterException { - List problems = super.check(StringSourceInfo.fromSourceStrings( + var problems = super.check(StringSourceInfo.fromSourceStrings( JavaVersion.JAVA_17, Map.ofEntries( dummySourceEntry("com.Example", "Test"), @@ -79,7 +78,7 @@ void testMultipleViolations() throws IOException, LinterException { @Test void testFalsePositive01() throws IOException, LinterException { - List problems = super.check(StringSourceInfo.fromSourceStrings( + var problems = super.check(StringSourceInfo.fromSourceStrings( JavaVersion.JAVA_17, Map.ofEntries( dummySourceEntry("edu.kit", "Test"), diff --git a/autograder-core/src/test/java/de/firemage/autograder/core/check/oop/TestClosedSetOfValues.java b/autograder-core/src/test/java/de/firemage/autograder/core/check/oop/TestClosedSetOfValues.java index 30329ee7..9e88bf97 100644 --- a/autograder-core/src/test/java/de/firemage/autograder/core/check/oop/TestClosedSetOfValues.java +++ b/autograder-core/src/test/java/de/firemage/autograder/core/check/oop/TestClosedSetOfValues.java @@ -1,11 +1,11 @@ package de.firemage.autograder.core.check.oop; -import de.firemage.autograder.core.LinterException; +import de.firemage.autograder.api.LinterException; import de.firemage.autograder.core.LocalizedMessage; import de.firemage.autograder.core.Problem; import de.firemage.autograder.core.ProblemType; import de.firemage.autograder.core.check.AbstractCheckTest; -import de.firemage.autograder.core.compiler.JavaVersion; +import de.firemage.autograder.api.JavaVersion; import de.firemage.autograder.core.file.StringSourceInfo; import org.junit.jupiter.api.Test; diff --git a/autograder-core/src/test/java/de/firemage/autograder/core/check/oop/TestConcreteCollectionCheck.java b/autograder-core/src/test/java/de/firemage/autograder/core/check/oop/TestConcreteCollectionCheck.java index 3bb0e848..8f621943 100644 --- a/autograder-core/src/test/java/de/firemage/autograder/core/check/oop/TestConcreteCollectionCheck.java +++ b/autograder-core/src/test/java/de/firemage/autograder/core/check/oop/TestConcreteCollectionCheck.java @@ -1,11 +1,11 @@ package de.firemage.autograder.core.check.oop; -import de.firemage.autograder.core.LinterException; +import de.firemage.autograder.api.LinterException; import de.firemage.autograder.core.LocalizedMessage; import de.firemage.autograder.core.Problem; import de.firemage.autograder.core.ProblemType; import de.firemage.autograder.core.check.AbstractCheckTest; -import de.firemage.autograder.core.compiler.JavaVersion; +import de.firemage.autograder.api.JavaVersion; import de.firemage.autograder.core.file.StringSourceInfo; import org.junit.jupiter.api.Test; import org.junit.jupiter.params.ParameterizedTest; diff --git a/autograder-core/src/test/java/de/firemage/autograder/core/check/oop/TestIOUISeparation.java b/autograder-core/src/test/java/de/firemage/autograder/core/check/oop/TestIOUISeparation.java index 948c4f80..f76a4eca 100644 --- a/autograder-core/src/test/java/de/firemage/autograder/core/check/oop/TestIOUISeparation.java +++ b/autograder-core/src/test/java/de/firemage/autograder/core/check/oop/TestIOUISeparation.java @@ -1,11 +1,11 @@ package de.firemage.autograder.core.check.oop; -import de.firemage.autograder.core.LinterException; +import de.firemage.autograder.api.LinterException; import de.firemage.autograder.core.LocalizedMessage; import de.firemage.autograder.core.Problem; import de.firemage.autograder.core.ProblemType; import de.firemage.autograder.core.check.AbstractCheckTest; -import de.firemage.autograder.core.compiler.JavaVersion; +import de.firemage.autograder.api.JavaVersion; import de.firemage.autograder.core.file.StringSourceInfo; import org.junit.jupiter.api.Test; diff --git a/autograder-core/src/test/java/de/firemage/autograder/core/check/oop/TestLeakedCollectionCheck.java b/autograder-core/src/test/java/de/firemage/autograder/core/check/oop/TestLeakedCollectionCheck.java index 3068a4c3..135c2554 100644 --- a/autograder-core/src/test/java/de/firemage/autograder/core/check/oop/TestLeakedCollectionCheck.java +++ b/autograder-core/src/test/java/de/firemage/autograder/core/check/oop/TestLeakedCollectionCheck.java @@ -1,11 +1,11 @@ package de.firemage.autograder.core.check.oop; -import de.firemage.autograder.core.LinterException; +import de.firemage.autograder.api.LinterException; import de.firemage.autograder.core.LocalizedMessage; import de.firemage.autograder.core.Problem; import de.firemage.autograder.core.ProblemType; import de.firemage.autograder.core.check.AbstractCheckTest; -import de.firemage.autograder.core.compiler.JavaVersion; +import de.firemage.autograder.api.JavaVersion; import de.firemage.autograder.core.file.StringSourceInfo; import org.junit.jupiter.api.Disabled; import org.junit.jupiter.api.Test; diff --git a/autograder-core/src/test/java/de/firemage/autograder/core/check/oop/TestMethodShouldBeStatic.java b/autograder-core/src/test/java/de/firemage/autograder/core/check/oop/TestMethodShouldBeStatic.java index cdc5513b..dc396bea 100644 --- a/autograder-core/src/test/java/de/firemage/autograder/core/check/oop/TestMethodShouldBeStatic.java +++ b/autograder-core/src/test/java/de/firemage/autograder/core/check/oop/TestMethodShouldBeStatic.java @@ -1,11 +1,11 @@ package de.firemage.autograder.core.check.oop; -import de.firemage.autograder.core.LinterException; +import de.firemage.autograder.api.LinterException; import de.firemage.autograder.core.LocalizedMessage; import de.firemage.autograder.core.Problem; import de.firemage.autograder.core.ProblemType; import de.firemage.autograder.core.check.AbstractCheckTest; -import de.firemage.autograder.core.compiler.JavaVersion; +import de.firemage.autograder.api.JavaVersion; import de.firemage.autograder.core.file.StringSourceInfo; import org.junit.jupiter.api.Test; diff --git a/autograder-core/src/test/java/de/firemage/autograder/core/check/oop/TestStaticBlock.java b/autograder-core/src/test/java/de/firemage/autograder/core/check/oop/TestStaticBlock.java index a47d49c8..3dac18c3 100644 --- a/autograder-core/src/test/java/de/firemage/autograder/core/check/oop/TestStaticBlock.java +++ b/autograder-core/src/test/java/de/firemage/autograder/core/check/oop/TestStaticBlock.java @@ -1,11 +1,11 @@ package de.firemage.autograder.core.check.oop; -import de.firemage.autograder.core.LinterException; +import de.firemage.autograder.api.LinterException; import de.firemage.autograder.core.LocalizedMessage; import de.firemage.autograder.core.Problem; import de.firemage.autograder.core.ProblemType; import de.firemage.autograder.core.check.AbstractCheckTest; -import de.firemage.autograder.core.compiler.JavaVersion; +import de.firemage.autograder.api.JavaVersion; import de.firemage.autograder.core.file.StringSourceInfo; import org.junit.jupiter.api.Test; diff --git a/autograder-core/src/test/java/de/firemage/autograder/core/check/oop/TestStaticFieldShouldBeInstanceCheck.java b/autograder-core/src/test/java/de/firemage/autograder/core/check/oop/TestStaticFieldShouldBeInstanceCheck.java index ee0e74e3..f81b7af9 100644 --- a/autograder-core/src/test/java/de/firemage/autograder/core/check/oop/TestStaticFieldShouldBeInstanceCheck.java +++ b/autograder-core/src/test/java/de/firemage/autograder/core/check/oop/TestStaticFieldShouldBeInstanceCheck.java @@ -1,11 +1,11 @@ package de.firemage.autograder.core.check.oop; -import de.firemage.autograder.core.LinterException; +import de.firemage.autograder.api.LinterException; import de.firemage.autograder.core.LocalizedMessage; import de.firemage.autograder.core.Problem; import de.firemage.autograder.core.ProblemType; import de.firemage.autograder.core.check.AbstractCheckTest; -import de.firemage.autograder.core.compiler.JavaVersion; +import de.firemage.autograder.api.JavaVersion; import de.firemage.autograder.core.file.StringSourceInfo; import org.junit.jupiter.api.Test; diff --git a/autograder-core/src/test/java/de/firemage/autograder/core/check/structure/TestDefaultPackageCheck.java b/autograder-core/src/test/java/de/firemage/autograder/core/check/structure/TestDefaultPackageCheck.java index 4d57c5fd..54896da3 100644 --- a/autograder-core/src/test/java/de/firemage/autograder/core/check/structure/TestDefaultPackageCheck.java +++ b/autograder-core/src/test/java/de/firemage/autograder/core/check/structure/TestDefaultPackageCheck.java @@ -1,12 +1,11 @@ package de.firemage.autograder.core.check.structure; -import de.firemage.autograder.core.LinterException; +import de.firemage.autograder.api.LinterException; import de.firemage.autograder.core.LocalizedMessage; -import de.firemage.autograder.core.Problem; import de.firemage.autograder.core.ProblemType; import de.firemage.autograder.core.file.StringSourceInfo; import de.firemage.autograder.core.check.AbstractCheckTest; -import de.firemage.autograder.core.compiler.JavaVersion; +import de.firemage.autograder.api.JavaVersion; import org.junit.jupiter.api.Test; import java.io.IOException; @@ -20,7 +19,7 @@ class TestDefaultPackageCheck extends AbstractCheckTest { @Test void test() throws IOException, LinterException { - List problems = super.check(StringSourceInfo.fromSourceString( + var problems = super.check(StringSourceInfo.fromSourceString( JavaVersion.JAVA_17, "Test", """ @@ -39,7 +38,7 @@ public static void main(String[] args) { @Test void testMultipleClasses() throws IOException, LinterException { - List problems = super.check(StringSourceInfo.fromSourceStrings( + var problems = super.check(StringSourceInfo.fromSourceStrings( JavaVersion.JAVA_17, Map.ofEntries( dummySourceEntry("com.example", "Test"), @@ -58,7 +57,7 @@ void testMultipleClasses() throws IOException, LinterException { @Test void testNoDefaultPackageUsed() throws LinterException, IOException { - List problems = super.check(StringSourceInfo.fromSourceStrings( + var problems = super.check(StringSourceInfo.fromSourceStrings( JavaVersion.JAVA_17, Map.ofEntries( dummySourceEntry("com.example", "Test"), diff --git a/autograder-core/src/test/java/de/firemage/autograder/core/check/structure/TestDuplicateCode.java b/autograder-core/src/test/java/de/firemage/autograder/core/check/structure/TestDuplicateCode.java index 3b23398f..626487e4 100644 --- a/autograder-core/src/test/java/de/firemage/autograder/core/check/structure/TestDuplicateCode.java +++ b/autograder-core/src/test/java/de/firemage/autograder/core/check/structure/TestDuplicateCode.java @@ -1,11 +1,11 @@ package de.firemage.autograder.core.check.structure; -import de.firemage.autograder.core.LinterException; +import de.firemage.autograder.api.LinterException; import de.firemage.autograder.core.LocalizedMessage; import de.firemage.autograder.core.Problem; import de.firemage.autograder.core.ProblemType; import de.firemage.autograder.core.check.AbstractCheckTest; -import de.firemage.autograder.core.compiler.JavaVersion; +import de.firemage.autograder.api.JavaVersion; import de.firemage.autograder.core.file.StringSourceInfo; import org.junit.jupiter.api.Disabled; import org.junit.jupiter.api.Test; diff --git a/autograder-core/src/test/java/de/firemage/autograder/core/check/structure/TestTooFewPackagesCheck.java b/autograder-core/src/test/java/de/firemage/autograder/core/check/structure/TestTooFewPackagesCheck.java index b05efdde..d2f232b6 100644 --- a/autograder-core/src/test/java/de/firemage/autograder/core/check/structure/TestTooFewPackagesCheck.java +++ b/autograder-core/src/test/java/de/firemage/autograder/core/check/structure/TestTooFewPackagesCheck.java @@ -1,11 +1,11 @@ package de.firemage.autograder.core.check.structure; -import de.firemage.autograder.core.LinterException; +import de.firemage.autograder.api.LinterException; import de.firemage.autograder.core.LocalizedMessage; import de.firemage.autograder.core.Problem; import de.firemage.autograder.core.ProblemType; import de.firemage.autograder.core.check.AbstractCheckTest; -import de.firemage.autograder.core.compiler.JavaVersion; +import de.firemage.autograder.api.JavaVersion; import de.firemage.autograder.core.file.StringSourceInfo; import org.junit.jupiter.api.Test; diff --git a/autograder-core/src/test/java/de/firemage/autograder/core/check/unnecessary/TestUnusedCodeElementCheck.java b/autograder-core/src/test/java/de/firemage/autograder/core/check/unnecessary/TestUnusedCodeElementCheck.java index 5debecee..a0796866 100644 --- a/autograder-core/src/test/java/de/firemage/autograder/core/check/unnecessary/TestUnusedCodeElementCheck.java +++ b/autograder-core/src/test/java/de/firemage/autograder/core/check/unnecessary/TestUnusedCodeElementCheck.java @@ -1,11 +1,11 @@ package de.firemage.autograder.core.check.unnecessary; -import de.firemage.autograder.core.LinterException; +import de.firemage.autograder.api.LinterException; import de.firemage.autograder.core.LocalizedMessage; import de.firemage.autograder.core.Problem; import de.firemage.autograder.core.ProblemType; import de.firemage.autograder.core.check.AbstractCheckTest; -import de.firemage.autograder.core.compiler.JavaVersion; +import de.firemage.autograder.api.JavaVersion; import de.firemage.autograder.core.file.StringSourceInfo; import org.junit.jupiter.api.Disabled; import org.junit.jupiter.api.Test; @@ -43,7 +43,7 @@ private static void assertProblemSize(int expectedSize, Collection proble @Test void testUnusedField() throws LinterException, IOException { - List problems = this.check(StringSourceInfo.fromSourceStrings( + var problems = this.check(StringSourceInfo.fromSourceStrings( JavaVersion.JAVA_17, Map.ofEntries( Map.entry( @@ -76,7 +76,7 @@ public class Example { @Test void testUnusedFieldWithShadowing() throws LinterException, IOException { - List problems = this.check(StringSourceInfo.fromSourceStrings( + var problems = this.check(StringSourceInfo.fromSourceStrings( JavaVersion.JAVA_17, Map.ofEntries( Map.entry( @@ -108,7 +108,7 @@ public static void main(String[] args) {} @Test void testUnusedRecursiveMethod() throws LinterException, IOException { - List problems = this.check(StringSourceInfo.fromSourceStrings( + var problems = this.check(StringSourceInfo.fromSourceStrings( JavaVersion.JAVA_17, Map.ofEntries( Map.entry( @@ -133,7 +133,7 @@ public static void main(String[] args) {} @Test // See: https://github.com/Feuermagier/autograder/issues/228 void testFieldUsedByInvocation() throws LinterException, IOException { - List problems = this.check(StringSourceInfo.fromSourceStrings( + var problems = this.check(StringSourceInfo.fromSourceStrings( JavaVersion.JAVA_17, Map.ofEntries( Map.entry( @@ -170,7 +170,7 @@ public String getRoot() { @Test void testUnusedTypeParameter() throws LinterException, IOException { - List problems = this.check(StringSourceInfo.fromSourceStrings( + var problems = this.check(StringSourceInfo.fromSourceStrings( JavaVersion.JAVA_17, Map.ofEntries( Map.entry( @@ -266,7 +266,7 @@ class Dog { @Test void testOnlyWrittenVariable() throws LinterException, IOException { // For now, this is not detected as unused, because it might result in false positives - List problems = this.check(StringSourceInfo.fromSourceStrings( + var problems = this.check(StringSourceInfo.fromSourceStrings( JavaVersion.JAVA_17, Map.ofEntries( Map.entry( @@ -291,7 +291,7 @@ public static void main(String[] args) { @Test void testUnusedMainMethod() throws LinterException, IOException { - List problems = this.check(StringSourceInfo.fromSourceStrings( + var problems = this.check(StringSourceInfo.fromSourceStrings( JavaVersion.JAVA_17, Map.ofEntries( Map.entry( @@ -311,7 +311,7 @@ public class Main { @Test void testUnusedMainMethodDefaultPackage() throws LinterException, IOException { - List problems = this.check(StringSourceInfo.fromSourceStrings( + var problems = this.check(StringSourceInfo.fromSourceStrings( JavaVersion.JAVA_17, Map.ofEntries( Map.entry( @@ -331,7 +331,7 @@ public static void main(String[] args) {} @Test void testUnusedExternalOverriddenMethod() throws LinterException, IOException { - List problems = this.check(StringSourceInfo.fromSourceStrings( + var problems = this.check(StringSourceInfo.fromSourceStrings( JavaVersion.JAVA_17, Map.ofEntries( Map.entry( @@ -355,7 +355,7 @@ public static void main(String[] args) {} @Test void testIndirectlyUsedEnumVariant() throws LinterException, IOException { - List problems = this.check(StringSourceInfo.fromSourceStrings( + var problems = this.check(StringSourceInfo.fromSourceStrings( JavaVersion.JAVA_17, Map.ofEntries( Map.entry( @@ -387,7 +387,7 @@ public enum MyEnum { @Test @Disabled("Unused types are not detected for now, because of potential false-positives") void testUnusedType() throws LinterException, IOException { - List problems = this.check(StringSourceInfo.fromSourceStrings( + var problems = this.check(StringSourceInfo.fromSourceStrings( JavaVersion.JAVA_17, Map.ofEntries( Map.entry( @@ -441,7 +441,7 @@ public static void main(String[] args) {} @Test void testUnusedPrivateConstructor() throws LinterException, IOException { - List problems = this.check(StringSourceInfo.fromSourceStrings( + var problems = this.check(StringSourceInfo.fromSourceStrings( JavaVersion.JAVA_17, Map.ofEntries( Map.entry( diff --git a/autograder-core/src/test/java/de/firemage/autograder/core/file/TestFileSourceInfo.java b/autograder-core/src/test/java/de/firemage/autograder/core/file/TestFileSourceInfo.java index ca5e6c8f..d980faae 100644 --- a/autograder-core/src/test/java/de/firemage/autograder/core/file/TestFileSourceInfo.java +++ b/autograder-core/src/test/java/de/firemage/autograder/core/file/TestFileSourceInfo.java @@ -1,6 +1,7 @@ package de.firemage.autograder.core.file; -import de.firemage.autograder.core.compiler.JavaVersion; +import de.firemage.autograder.api.JavaVersion; +import de.firemage.autograder.api.AbstractTempLocation; import org.junit.jupiter.api.Test; import java.io.IOException; @@ -12,13 +13,13 @@ import static org.junit.jupiter.api.Assertions.assertEquals; class TestFileSourceInfo { - private final TempLocation tempLocation = TempLocation.random(); + private final AbstractTempLocation tempLocation = TempLocation.random(); // See https://github.com/Feuermagier/autograder/issues/368 @Test void testDetectThaiEncoding() throws IOException { - try (TempLocation folder = tempLocation.createTempDirectory("test")) { - Path folderPath = folder.tempLocation().toPath(); + try (AbstractTempLocation folder = tempLocation.createTempDirectory("test")) { + Path folderPath = folder.toPath(); Path filePath = Paths.get(folderPath.toString(), "Test.java"); Files.write(filePath, "public class Test { char symbol = 'ยง'; }".getBytes()); diff --git a/autograder-core/src/test/java/de/firemage/autograder/core/framework/TestConfig.java b/autograder-core/src/test/java/de/firemage/autograder/core/framework/TestConfig.java index 5ee2de1d..67a84812 100644 --- a/autograder-core/src/test/java/de/firemage/autograder/core/framework/TestConfig.java +++ b/autograder-core/src/test/java/de/firemage/autograder/core/framework/TestConfig.java @@ -6,7 +6,6 @@ import java.lang.reflect.InvocationTargetException; import java.nio.file.Files; import java.nio.file.Path; -import java.util.ArrayList; import java.util.List; public record TestConfig(List lines) { diff --git a/autograder-core/src/test/java/de/firemage/autograder/core/framework/TestFramework.java b/autograder-core/src/test/java/de/firemage/autograder/core/framework/TestFramework.java index d779cc43..77964208 100644 --- a/autograder-core/src/test/java/de/firemage/autograder/core/framework/TestFramework.java +++ b/autograder-core/src/test/java/de/firemage/autograder/core/framework/TestFramework.java @@ -1,10 +1,12 @@ package de.firemage.autograder.core.framework; -import de.firemage.autograder.core.CheckConfiguration; +import de.firemage.autograder.api.CheckConfiguration; +import de.firemage.autograder.api.AbstractLinter; import de.firemage.autograder.core.Linter; -import de.firemage.autograder.core.LinterException; -import de.firemage.autograder.core.file.TempLocation; +import de.firemage.autograder.api.LinterException; +import de.firemage.autograder.api.AbstractTempLocation; import de.firemage.autograder.core.file.SourcePath; +import de.firemage.autograder.core.file.TempLocation; import de.firemage.autograder.core.file.UploadedFile; import org.junit.jupiter.api.DynamicTest; import org.junit.jupiter.api.TestFactory; @@ -45,7 +47,7 @@ Stream createCheckTests() throws URISyntaxException, IOException { folders = paths.toList(); } - try (TempLocation tempLocation = TempLocation.random()) { + try (AbstractTempLocation tempLocation = TempLocation.random()) { return DynamicTest.stream( folders.stream().map(TestInput::new) .filter(testInput -> ONLY_TEST.isEmpty() || ONLY_TEST.contains(testInput.config().checkPath())), @@ -58,19 +60,18 @@ Stream createCheckTests() throws URISyntaxException, IOException { } } - private static List runAutograder(TestInput testInput, TempLocation tempLocation) throws LinterException, IOException, ClassNotFoundException, InvocationTargetException, NoSuchMethodException, InstantiationException, IllegalAccessException { + private static List runAutograder(TestInput testInput, AbstractTempLocation tempLocation) throws LinterException, IOException, ClassNotFoundException, InvocationTargetException, NoSuchMethodException, InstantiationException, IllegalAccessException { var check = testInput.config().check(); - try (TempLocation tmpDirectory = tempLocation.createTempDirectory(testInput.config().checkPath())) { + try (var tmpDirectory = tempLocation.createTempDirectory(testInput.config().checkPath())) { var file = UploadedFile.build( testInput.sourceInfo(), tmpDirectory, status -> { }, null ); - var linter = Linter.builder(Locale.US) + var linter = new Linter(AbstractLinter.builder(Locale.US) .threads(1) // Use a single thread for performance reasons - .tempLocation(tmpDirectory) - .build(); + .tempLocation(tmpDirectory)); var problems = linter.checkFile( file, diff --git a/autograder-core/src/test/java/de/firemage/autograder/core/framework/TestInput.java b/autograder-core/src/test/java/de/firemage/autograder/core/framework/TestInput.java index 21b5ed16..704829e1 100644 --- a/autograder-core/src/test/java/de/firemage/autograder/core/framework/TestInput.java +++ b/autograder-core/src/test/java/de/firemage/autograder/core/framework/TestInput.java @@ -1,7 +1,7 @@ package de.firemage.autograder.core.framework; import de.firemage.autograder.core.ProblemType; -import de.firemage.autograder.core.compiler.JavaVersion; +import de.firemage.autograder.api.JavaVersion; import de.firemage.autograder.core.file.SourceInfo; import de.firemage.autograder.core.file.SourcePath; import de.firemage.autograder.core.file.StringSourceInfo; @@ -20,7 +20,6 @@ import java.util.regex.Matcher; import java.util.regex.Pattern; import java.util.stream.Collectors; -import java.util.stream.Stream; public final class TestInput { private static final Logger LOGGER = LoggerFactory.getLogger(TestInput.class); diff --git a/autograder-core/src/test/java/de/firemage/autograder/core/integrated/MethodHierarchyTest.java b/autograder-core/src/test/java/de/firemage/autograder/core/integrated/MethodHierarchyTest.java index 0e4894a1..ad678c56 100644 --- a/autograder-core/src/test/java/de/firemage/autograder/core/integrated/MethodHierarchyTest.java +++ b/autograder-core/src/test/java/de/firemage/autograder/core/integrated/MethodHierarchyTest.java @@ -1,11 +1,12 @@ package de.firemage.autograder.core.integrated; import de.firemage.autograder.core.CodeModel; -import de.firemage.autograder.core.LinterException; -import de.firemage.autograder.core.compiler.JavaVersion; -import de.firemage.autograder.core.file.TempLocation; +import de.firemage.autograder.api.LinterException; +import de.firemage.autograder.api.JavaVersion; +import de.firemage.autograder.api.AbstractTempLocation; import de.firemage.autograder.core.file.SourceInfo; import de.firemage.autograder.core.file.StringSourceInfo; +import de.firemage.autograder.core.file.TempLocation; import de.firemage.autograder.core.file.UploadedFile; import org.junit.jupiter.api.Test; import spoon.reflect.code.CtLambda; diff --git a/autograder-core/src/test/java/de/firemage/autograder/core/integrated/structure/TestStructuralEqualsVisitor.java b/autograder-core/src/test/java/de/firemage/autograder/core/integrated/structure/TestStructuralEqualsVisitor.java index 364d424b..632c5da5 100644 --- a/autograder-core/src/test/java/de/firemage/autograder/core/integrated/structure/TestStructuralEqualsVisitor.java +++ b/autograder-core/src/test/java/de/firemage/autograder/core/integrated/structure/TestStructuralEqualsVisitor.java @@ -1,8 +1,8 @@ package de.firemage.autograder.core.integrated.structure; -import de.firemage.autograder.core.compiler.JavaVersion; -import de.firemage.autograder.core.file.TempLocation; +import de.firemage.autograder.api.JavaVersion; import de.firemage.autograder.core.file.StringSourceInfo; +import de.firemage.autograder.core.file.TempLocation; import de.firemage.autograder.core.file.UploadedFile; import org.junit.jupiter.params.ParameterizedTest; import org.junit.jupiter.params.provider.CsvSource; diff --git a/autograder-extra/pom.xml b/autograder-extra/pom.xml index a451af36..f683939c 100644 --- a/autograder-extra/pom.xml +++ b/autograder-extra/pom.xml @@ -21,6 +21,10 @@ + + de.firemage.autograder + autograder-api + de.firemage.autograder autograder-core @@ -30,7 +34,7 @@ de.firemage.autograder autograder-core - ${parent.version} + ${project.parent.version} tests test-jar test diff --git a/autograder-extra/src/main/java/de/firemage/autograder/extra/errorprone/ErrorProneCheck.java b/autograder-extra/src/main/java/de/firemage/autograder/extra/errorprone/ErrorProneCheck.java index cda7877f..589722c6 100644 --- a/autograder-extra/src/main/java/de/firemage/autograder/extra/errorprone/ErrorProneCheck.java +++ b/autograder-extra/src/main/java/de/firemage/autograder/extra/errorprone/ErrorProneCheck.java @@ -1,5 +1,6 @@ package de.firemage.autograder.extra.errorprone; +import de.firemage.autograder.api.Translatable; import de.firemage.autograder.core.LocalizedMessage; import de.firemage.autograder.core.check.Check; @@ -19,7 +20,7 @@ public interface ErrorProneCheck extends Check { Map> subscribedLints(); @Override - default LocalizedMessage getLinter() { + default Translatable getLinter() { return new LocalizedMessage("linter-error-prone"); } } diff --git a/autograder-extra/src/main/java/de/firemage/autograder/extra/errorprone/ErrorProneCompiler.java b/autograder-extra/src/main/java/de/firemage/autograder/extra/errorprone/ErrorProneCompiler.java index c6697094..62787ceb 100644 --- a/autograder-extra/src/main/java/de/firemage/autograder/extra/errorprone/ErrorProneCompiler.java +++ b/autograder-extra/src/main/java/de/firemage/autograder/extra/errorprone/ErrorProneCompiler.java @@ -2,8 +2,8 @@ import de.firemage.autograder.core.file.CompilationUnit; import de.firemage.autograder.core.file.SourceInfo; -import de.firemage.autograder.core.compiler.JavaVersion; -import de.firemage.autograder.core.file.TempLocation; +import de.firemage.autograder.api.JavaVersion; +import de.firemage.autograder.api.AbstractTempLocation; import javax.tools.DiagnosticCollector; import javax.tools.JavaCompiler; @@ -25,7 +25,7 @@ * @param javaVersion the java version with which to compile * @param lints the lints that should be emitted */ -record ErrorProneCompiler(JavaVersion javaVersion, TempLocation tempLocation, +record ErrorProneCompiler(JavaVersion javaVersion, AbstractTempLocation tempLocation, List lints) implements Serializable { /** * Compiles the given source files and returns the emitted lints. @@ -80,7 +80,7 @@ private List internalCompile(SourceInfo input) throws IOEx StringWriter output = new StringWriter(); boolean isSuccessful; - try (TempLocation tempLocation = this.tempLocation.createTempDirectory("classes")) { + try (AbstractTempLocation tempLocation = this.tempLocation.createTempDirectory("classes")) { isSuccessful = compiler.getTask( output, compiler.getStandardFileManager(diagnosticCollector, Locale.US, charset), diff --git a/autograder-extra/src/main/java/de/firemage/autograder/extra/errorprone/ErrorProneLinter.java b/autograder-extra/src/main/java/de/firemage/autograder/extra/errorprone/ErrorProneLinter.java index 5059e62b..f673b94f 100644 --- a/autograder-extra/src/main/java/de/firemage/autograder/extra/errorprone/ErrorProneLinter.java +++ b/autograder-extra/src/main/java/de/firemage/autograder/extra/errorprone/ErrorProneLinter.java @@ -1,11 +1,12 @@ package de.firemage.autograder.extra.errorprone; +import de.firemage.autograder.api.Translatable; import de.firemage.autograder.core.CodeLinter; import de.firemage.autograder.core.LinterStatus; import de.firemage.autograder.core.Problem; import de.firemage.autograder.core.file.SourceInfo; import de.firemage.autograder.core.check.Check; -import de.firemage.autograder.core.file.TempLocation; +import de.firemage.autograder.api.AbstractTempLocation; import de.firemage.autograder.core.file.UploadedFile; import java.io.IOException; @@ -24,12 +25,12 @@ public Class supportedCheckType() { public List lint( UploadedFile submission, - TempLocation tempLocation, + AbstractTempLocation tempLocation, ClassLoader classLoader, List checks, - Consumer statusConsumer + Consumer statusConsumer ) throws IOException { - statusConsumer.accept(LinterStatus.RUNNING_ERROR_PRONE); + statusConsumer.accept(LinterStatus.RUNNING_ERROR_PRONE.getMessage()); Map> lintsForChecks = new HashMap<>(); Map checksForLints = new HashMap<>(); diff --git a/autograder-extra/src/main/java/de/firemage/autograder/extra/errorprone/Message.java b/autograder-extra/src/main/java/de/firemage/autograder/extra/errorprone/Message.java index 427a4ae7..ca2a982d 100644 --- a/autograder-extra/src/main/java/de/firemage/autograder/extra/errorprone/Message.java +++ b/autograder-extra/src/main/java/de/firemage/autograder/extra/errorprone/Message.java @@ -1,9 +1,8 @@ package de.firemage.autograder.extra.errorprone; import de.firemage.autograder.core.CodePosition; -import de.firemage.autograder.core.ProblemImpl; -import de.firemage.autograder.core.LocalizedMessage; import de.firemage.autograder.core.Problem; +import de.firemage.autograder.core.LocalizedMessage; import de.firemage.autograder.core.ProblemType; import de.firemage.autograder.core.check.Check; @@ -21,7 +20,7 @@ public static Message of(ProblemType problemType, LocalizedMessage message) { } Problem toProblem(Check check, CodePosition position) { - return new ProblemImpl(check, position, this.message, this.problemType) { + return new Problem(check, position, this.message, this.problemType) { }; } } diff --git a/autograder-extra/src/main/java/de/firemage/autograder/extra/errorprone/VMLauncher.java b/autograder-extra/src/main/java/de/firemage/autograder/extra/errorprone/VMLauncher.java index 2cb553bb..64927529 100644 --- a/autograder-extra/src/main/java/de/firemage/autograder/extra/errorprone/VMLauncher.java +++ b/autograder-extra/src/main/java/de/firemage/autograder/extra/errorprone/VMLauncher.java @@ -1,6 +1,6 @@ package de.firemage.autograder.extra.errorprone; -import de.firemage.autograder.core.file.TempLocation; +import de.firemage.autograder.api.AbstractTempLocation; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; @@ -25,8 +25,8 @@ * @param jvmArgs arguments to pass to the new JVM (those are that java -... flags) * @param tempLocation a location where the result of the code can be written to (used for inter-process communication) */ -public record VMLauncher(List jvmArgs, TempLocation tempLocation, Optional mainClassName) { - public static VMLauncher fromDefault(TempLocation tmpLocation) throws IOException { +public record VMLauncher(List jvmArgs, AbstractTempLocation tempLocation, Optional mainClassName) { + public static VMLauncher fromDefault(AbstractTempLocation tmpLocation) throws IOException { Optional mainClassName = Optional.empty(); { String potentialName = System.getProperty("sun.java.command"); diff --git a/autograder-extra/src/main/java/de/firemage/autograder/extra/pmd/PMDCheck.java b/autograder-extra/src/main/java/de/firemage/autograder/extra/pmd/PMDCheck.java index 8b0d627c..87f0c44f 100644 --- a/autograder-extra/src/main/java/de/firemage/autograder/extra/pmd/PMDCheck.java +++ b/autograder-extra/src/main/java/de/firemage/autograder/extra/pmd/PMDCheck.java @@ -2,7 +2,7 @@ import de.firemage.autograder.core.LocalizedMessage; import de.firemage.autograder.core.ProblemType; -import de.firemage.autograder.core.Translatable; +import de.firemage.autograder.api.Translatable; import de.firemage.autograder.core.check.Check; import net.sourceforge.pmd.Rule; import net.sourceforge.pmd.RuleViolation; diff --git a/autograder-extra/src/main/java/de/firemage/autograder/extra/pmd/PMDInCodeProblem.java b/autograder-extra/src/main/java/de/firemage/autograder/extra/pmd/PMDInCodeProblem.java index 593a344f..126d67ab 100644 --- a/autograder-extra/src/main/java/de/firemage/autograder/extra/pmd/PMDInCodeProblem.java +++ b/autograder-extra/src/main/java/de/firemage/autograder/extra/pmd/PMDInCodeProblem.java @@ -1,14 +1,14 @@ package de.firemage.autograder.extra.pmd; import de.firemage.autograder.core.CodePosition; -import de.firemage.autograder.core.ProblemImpl; +import de.firemage.autograder.core.Problem; import de.firemage.autograder.core.LocalizedMessage; import de.firemage.autograder.core.file.SourceInfo; import net.sourceforge.pmd.RuleViolation; import java.nio.file.Path; -public class PMDInCodeProblem extends ProblemImpl { +public class PMDInCodeProblem extends Problem { public PMDInCodeProblem(PMDCheck check, RuleViolation violation, SourceInfo sourceInfo) { super(check, diff --git a/autograder-extra/src/main/java/de/firemage/autograder/extra/pmd/PMDLinter.java b/autograder-extra/src/main/java/de/firemage/autograder/extra/pmd/PMDLinter.java index 8d2a2e41..2cb8641f 100644 --- a/autograder-extra/src/main/java/de/firemage/autograder/extra/pmd/PMDLinter.java +++ b/autograder-extra/src/main/java/de/firemage/autograder/extra/pmd/PMDLinter.java @@ -1,10 +1,11 @@ package de.firemage.autograder.extra.pmd; +import de.firemage.autograder.api.Translatable; import de.firemage.autograder.core.CodeLinter; import de.firemage.autograder.core.LinterStatus; import de.firemage.autograder.core.Problem; import de.firemage.autograder.core.file.CompilationUnit; -import de.firemage.autograder.core.file.TempLocation; +import de.firemage.autograder.api.AbstractTempLocation; import de.firemage.autograder.core.file.UploadedFile; import net.sourceforge.pmd.PMDConfiguration; import net.sourceforge.pmd.PmdAnalysis; @@ -34,12 +35,12 @@ public Class supportedCheckType() { @Override public List lint( UploadedFile submission, - TempLocation tempLocation, + AbstractTempLocation tempLocation, ClassLoader classLoader, List checks, - Consumer statusConsumer + Consumer statusConsumer ) throws IOException { - statusConsumer.accept(LinterStatus.RUNNING_PMD); + statusConsumer.accept(LinterStatus.RUNNING_PMD.getMessage()); PMDConfiguration config = new PMDConfiguration(); diff --git a/autograder-extra/src/test/java/de/firemage/autograder/extra/check/TestLocalizedStrings.java b/autograder-extra/src/test/java/de/firemage/autograder/extra/check/TestLocalizedStrings.java index 87634e62..2910f8e5 100644 --- a/autograder-extra/src/test/java/de/firemage/autograder/extra/check/TestLocalizedStrings.java +++ b/autograder-extra/src/test/java/de/firemage/autograder/extra/check/TestLocalizedStrings.java @@ -1,7 +1,7 @@ package de.firemage.autograder.extra.check; import de.firemage.autograder.core.Linter; -import de.firemage.autograder.core.compiler.JavaVersion; +import de.firemage.autograder.api.JavaVersion; import de.firemage.autograder.core.integrated.SpoonUtil; import de.firemage.autograder.extra.check.naming.LinguisticNamingCheck; import de.firemage.autograder.extra.check.naming.VariablesHaveDescriptiveNamesCheck; diff --git a/autograder-extra/src/test/java/de/firemage/autograder/extra/check/api/TestProblematicEqualsHashCodeComparable.java b/autograder-extra/src/test/java/de/firemage/autograder/extra/check/api/TestProblematicEqualsHashCodeComparable.java index 22f5469e..17fdd1ef 100644 --- a/autograder-extra/src/test/java/de/firemage/autograder/extra/check/api/TestProblematicEqualsHashCodeComparable.java +++ b/autograder-extra/src/test/java/de/firemage/autograder/extra/check/api/TestProblematicEqualsHashCodeComparable.java @@ -1,11 +1,11 @@ package de.firemage.autograder.extra.check.api; -import de.firemage.autograder.core.LinterException; +import de.firemage.autograder.api.LinterException; import de.firemage.autograder.core.LocalizedMessage; import de.firemage.autograder.core.Problem; import de.firemage.autograder.core.ProblemType; import de.firemage.autograder.core.check.AbstractCheckTest; -import de.firemage.autograder.core.compiler.JavaVersion; +import de.firemage.autograder.api.JavaVersion; import de.firemage.autograder.core.file.StringSourceInfo; import org.junit.jupiter.api.Test; diff --git a/autograder-extra/src/test/java/de/firemage/autograder/extra/check/complexity/TestDiamondOperatorCheck.java b/autograder-extra/src/test/java/de/firemage/autograder/extra/check/complexity/TestDiamondOperatorCheck.java index d8a0f8f3..1721261c 100644 --- a/autograder-extra/src/test/java/de/firemage/autograder/extra/check/complexity/TestDiamondOperatorCheck.java +++ b/autograder-extra/src/test/java/de/firemage/autograder/extra/check/complexity/TestDiamondOperatorCheck.java @@ -1,11 +1,11 @@ package de.firemage.autograder.extra.check.complexity; -import de.firemage.autograder.core.LinterException; +import de.firemage.autograder.api.LinterException; import de.firemage.autograder.core.LocalizedMessage; import de.firemage.autograder.core.Problem; import de.firemage.autograder.core.ProblemType; import de.firemage.autograder.core.check.AbstractCheckTest; -import de.firemage.autograder.core.compiler.JavaVersion; +import de.firemage.autograder.api.JavaVersion; import de.firemage.autograder.core.file.StringSourceInfo; import org.junit.jupiter.api.Test; diff --git a/autograder-extra/src/test/java/de/firemage/autograder/extra/check/complexity/TestRedundantReturnCheck.java b/autograder-extra/src/test/java/de/firemage/autograder/extra/check/complexity/TestRedundantReturnCheck.java index dd05cd9b..b7fec0d6 100644 --- a/autograder-extra/src/test/java/de/firemage/autograder/extra/check/complexity/TestRedundantReturnCheck.java +++ b/autograder-extra/src/test/java/de/firemage/autograder/extra/check/complexity/TestRedundantReturnCheck.java @@ -1,11 +1,11 @@ package de.firemage.autograder.extra.check.complexity; -import de.firemage.autograder.core.LinterException; +import de.firemage.autograder.api.LinterException; import de.firemage.autograder.core.LocalizedMessage; import de.firemage.autograder.core.Problem; import de.firemage.autograder.core.ProblemType; import de.firemage.autograder.core.check.AbstractCheckTest; -import de.firemage.autograder.core.compiler.JavaVersion; +import de.firemage.autograder.api.JavaVersion; import de.firemage.autograder.core.file.StringSourceInfo; import org.junit.jupiter.api.Test; diff --git a/autograder-extra/src/test/java/de/firemage/autograder/extra/check/complexity/TestRegexCheck.java b/autograder-extra/src/test/java/de/firemage/autograder/extra/check/complexity/TestRegexCheck.java index 2e484862..1b2c184a 100644 --- a/autograder-extra/src/test/java/de/firemage/autograder/extra/check/complexity/TestRegexCheck.java +++ b/autograder-extra/src/test/java/de/firemage/autograder/extra/check/complexity/TestRegexCheck.java @@ -1,11 +1,11 @@ package de.firemage.autograder.extra.check.complexity; -import de.firemage.autograder.core.LinterException; +import de.firemage.autograder.api.LinterException; import de.firemage.autograder.core.LocalizedMessage; import de.firemage.autograder.core.Problem; import de.firemage.autograder.core.ProblemType; import de.firemage.autograder.core.check.AbstractCheckTest; -import de.firemage.autograder.core.compiler.JavaVersion; +import de.firemage.autograder.api.JavaVersion; import de.firemage.autograder.core.file.StringSourceInfo; import org.junit.jupiter.api.Test; diff --git a/autograder-extra/src/test/java/de/firemage/autograder/extra/check/general/TestConstantNamingAndQualifierCheck.java b/autograder-extra/src/test/java/de/firemage/autograder/extra/check/general/TestConstantNamingAndQualifierCheck.java index c9790341..c16393bc 100644 --- a/autograder-extra/src/test/java/de/firemage/autograder/extra/check/general/TestConstantNamingAndQualifierCheck.java +++ b/autograder-extra/src/test/java/de/firemage/autograder/extra/check/general/TestConstantNamingAndQualifierCheck.java @@ -1,12 +1,12 @@ package de.firemage.autograder.extra.check.general; -import de.firemage.autograder.core.LinterException; +import de.firemage.autograder.api.LinterException; import de.firemage.autograder.core.LocalizedMessage; import de.firemage.autograder.core.Problem; import de.firemage.autograder.core.ProblemType; import de.firemage.autograder.core.file.StringSourceInfo; import de.firemage.autograder.core.check.AbstractCheckTest; -import de.firemage.autograder.core.compiler.JavaVersion; +import de.firemage.autograder.api.JavaVersion; import org.junit.jupiter.api.Test; import java.io.IOException; diff --git a/autograder-extra/src/test/java/de/firemage/autograder/extra/check/general/TestDoubleBraceInitializationCheck.java b/autograder-extra/src/test/java/de/firemage/autograder/extra/check/general/TestDoubleBraceInitializationCheck.java index 91599878..b2181830 100644 --- a/autograder-extra/src/test/java/de/firemage/autograder/extra/check/general/TestDoubleBraceInitializationCheck.java +++ b/autograder-extra/src/test/java/de/firemage/autograder/extra/check/general/TestDoubleBraceInitializationCheck.java @@ -1,11 +1,11 @@ package de.firemage.autograder.extra.check.general; -import de.firemage.autograder.core.LinterException; +import de.firemage.autograder.api.LinterException; import de.firemage.autograder.core.LocalizedMessage; import de.firemage.autograder.core.Problem; import de.firemage.autograder.core.ProblemType; import de.firemage.autograder.core.check.AbstractCheckTest; -import de.firemage.autograder.core.compiler.JavaVersion; +import de.firemage.autograder.api.JavaVersion; import de.firemage.autograder.core.file.StringSourceInfo; import org.junit.jupiter.api.Test; diff --git a/autograder-extra/src/test/java/de/firemage/autograder/extra/check/general/TestUseDifferentVisibility.java b/autograder-extra/src/test/java/de/firemage/autograder/extra/check/general/TestUseDifferentVisibility.java index aeff1ccf..f5000f6d 100644 --- a/autograder-extra/src/test/java/de/firemage/autograder/extra/check/general/TestUseDifferentVisibility.java +++ b/autograder-extra/src/test/java/de/firemage/autograder/extra/check/general/TestUseDifferentVisibility.java @@ -1,11 +1,11 @@ package de.firemage.autograder.extra.check.general; -import de.firemage.autograder.core.LinterException; +import de.firemage.autograder.api.LinterException; import de.firemage.autograder.core.LocalizedMessage; import de.firemage.autograder.core.Problem; import de.firemage.autograder.core.ProblemType; import de.firemage.autograder.core.check.AbstractCheckTest; -import de.firemage.autograder.core.compiler.JavaVersion; +import de.firemage.autograder.api.JavaVersion; import de.firemage.autograder.core.file.StringSourceInfo; import org.junit.jupiter.api.Test; diff --git a/autograder-extra/src/test/java/de/firemage/autograder/extra/check/naming/TestLinguisticNamingCheck.java b/autograder-extra/src/test/java/de/firemage/autograder/extra/check/naming/TestLinguisticNamingCheck.java index c10dccd7..dd5b0c51 100644 --- a/autograder-extra/src/test/java/de/firemage/autograder/extra/check/naming/TestLinguisticNamingCheck.java +++ b/autograder-extra/src/test/java/de/firemage/autograder/extra/check/naming/TestLinguisticNamingCheck.java @@ -1,11 +1,11 @@ package de.firemage.autograder.extra.check.naming; -import de.firemage.autograder.core.LinterException; +import de.firemage.autograder.api.LinterException; import de.firemage.autograder.core.LocalizedMessage; import de.firemage.autograder.core.Problem; import de.firemage.autograder.core.ProblemType; import de.firemage.autograder.core.check.AbstractCheckTest; -import de.firemage.autograder.core.compiler.JavaVersion; +import de.firemage.autograder.api.JavaVersion; import de.firemage.autograder.core.file.StringSourceInfo; import org.junit.jupiter.api.Test; diff --git a/autograder-extra/src/test/java/de/firemage/autograder/extra/check/naming/TestVariablesHaveDescriptiveNamesCheck.java b/autograder-extra/src/test/java/de/firemage/autograder/extra/check/naming/TestVariablesHaveDescriptiveNamesCheck.java index bf9f55f5..0c896bb8 100644 --- a/autograder-extra/src/test/java/de/firemage/autograder/extra/check/naming/TestVariablesHaveDescriptiveNamesCheck.java +++ b/autograder-extra/src/test/java/de/firemage/autograder/extra/check/naming/TestVariablesHaveDescriptiveNamesCheck.java @@ -1,11 +1,11 @@ package de.firemage.autograder.extra.check.naming; -import de.firemage.autograder.core.LinterException; +import de.firemage.autograder.api.LinterException; import de.firemage.autograder.core.LocalizedMessage; import de.firemage.autograder.core.Problem; import de.firemage.autograder.core.ProblemType; import de.firemage.autograder.core.check.AbstractCheckTest; -import de.firemage.autograder.core.compiler.JavaVersion; +import de.firemage.autograder.api.JavaVersion; import de.firemage.autograder.core.file.StringSourceInfo; import org.junit.jupiter.api.Test; diff --git a/autograder-extra/src/test/java/de/firemage/autograder/extra/check/oop/TestInheritanceBadPractices.java b/autograder-extra/src/test/java/de/firemage/autograder/extra/check/oop/TestInheritanceBadPractices.java index a45a39ac..834d27c1 100644 --- a/autograder-extra/src/test/java/de/firemage/autograder/extra/check/oop/TestInheritanceBadPractices.java +++ b/autograder-extra/src/test/java/de/firemage/autograder/extra/check/oop/TestInheritanceBadPractices.java @@ -1,12 +1,11 @@ package de.firemage.autograder.extra.check.oop; -import de.firemage.autograder.core.LinterException; +import de.firemage.autograder.api.LinterException; import de.firemage.autograder.core.LocalizedMessage; -import de.firemage.autograder.core.Problem; import de.firemage.autograder.core.ProblemType; import de.firemage.autograder.core.file.StringSourceInfo; import de.firemage.autograder.core.check.AbstractCheckTest; -import de.firemage.autograder.core.compiler.JavaVersion; +import de.firemage.autograder.api.JavaVersion; import org.junit.jupiter.api.Test; import java.io.IOException; @@ -25,7 +24,7 @@ class TestInheritanceBadPractices extends AbstractCheckTest { @Test void testCompositionMessage() throws LinterException, IOException { - List problems = this.check(StringSourceInfo.fromSourceString( + var problems = this.check(StringSourceInfo.fromSourceString( JavaVersion.JAVA_17, "Test", """ diff --git a/pom.xml b/pom.xml index f86b4d0f..53b371ea 100644 --- a/pom.xml +++ b/pom.xml @@ -46,6 +46,8 @@ 2.0.13 2.17.0 11.0.0 + 0.70 + 0.10.2 0.5.13 @@ -74,6 +76,11 @@ + + de.firemage.autograder + autograder-api + 0.5.41 + de.firemage.autograder autograder-core @@ -99,6 +106,12 @@ autograder-extra 0.5.41 + + + org.reflections + reflections + ${reflections.version} + @@ -230,6 +243,7 @@ + autograder-api autograder-core autograder-cmd autograder-treeg @@ -244,6 +258,7 @@ true + autograder-api autograder-core autograder-cmd autograder-treeg