Skip to content

Commit

Permalink
fix bug where non-empty javadoc was considered empty
Browse files Browse the repository at this point in the history
  • Loading branch information
Luro02 committed Dec 17, 2024
1 parent 4f95b72 commit cd41fbc
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import de.firemage.autograder.core.integrated.StaticAnalysis;
import spoon.processing.AbstractProcessor;
import spoon.reflect.code.CtComment;
import spoon.reflect.code.CtJavaDoc;
import spoon.reflect.declaration.CtElement;

import java.util.ArrayList;
Expand All @@ -30,7 +31,7 @@ private void checkComments(Collection<? extends CtComment> comments) {
}

for (CtComment ctComment : comments) {
if (ctComment.getContent().isBlank()) {
if (ctComment.getContent().isBlank() && !(ctComment instanceof CtJavaDoc ctJavaDoc && ctJavaDoc.getJavadocElements().isEmpty())) {
addLocalProblem(
ctComment,
new LocalizedMessage("unnecessary-comment-empty"),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,4 +101,48 @@ public Test() {

problems.assertExhausted();
}

@Test
void testPartiallyFilledJavadoc() throws IOException, LinterException {
ProblemIterator problems = this.checkIterator(
StringSourceInfo.fromSourceString(
JavaVersion.JAVA_17,
"edu.kit.kastel.Main",
"""
package edu.kit.kastel;
/**
*
* @author uxxxx
*/
public class Main {
}
"""
),
PROBLEM_TYPES
);

problems.assertExhausted();
}

@Test
void testPartiallyFilledJavadocNoPackage() throws IOException, LinterException {
ProblemIterator problems = this.checkIterator(
StringSourceInfo.fromSourceString(
JavaVersion.JAVA_17,
"Main",
"""
/**
*
* @author uxxxx
*/
public class Main {
}
"""
),
PROBLEM_TYPES
);

problems.assertExhausted();
}
}

0 comments on commit cd41fbc

Please sign in to comment.