Skip to content

Commit 216621f

Browse files
authored
Fix/requirements check (#6)
* Wrong order of method chain * Do not check custom student classes * Ignore throwables
1 parent 35798af commit 216621f

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

src/graderPrivate/java/h10/PrivateTutorUtils.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -248,9 +248,9 @@ private static Set<ConstructorLink> collectConstructorCalls(
248248
element.getElements(CtConstructorCall.class::isInstance).stream()
249249
.map(CtConstructorCall.class::cast)
250250
.map(CtConstructorCall::getExecutable)
251+
.map(CtExecutableReference::getActualConstructor)
251252
// null if the constructor is not found
252253
.filter(Predicate.not(Objects::isNull))
253-
.map(CtExecutableReference::getActualConstructor)
254254
.map(BasicConstructorLink::of)
255255
.filter(Predicate.not(visited::contains))
256256
.distinct()
@@ -321,9 +321,13 @@ public static void assertUseOnlyConstructorCalls(String methodName, List<? exten
321321
.map(BasicConstructorLink::reflection)
322322
.map(Constructor::getDeclaringClass)
323323
.distinct()
324+
// Ignore custom project classes and throwables
325+
.filter(clazz -> !clazz.getName().contains("h10") && !Throwable.class.isAssignableFrom(clazz))
324326
.map(BasicTypeLink::of)
325327
.collect(Collectors.toSet());
328+
326329
allowedClasses.forEach(found::remove);
330+
327331
assertEquals(
328332
0,
329333
found.size(),

0 commit comments

Comments
 (0)