Skip to content

Commit

Permalink
fix(#179): no declaration in Programs#defects()
Browse files Browse the repository at this point in the history
  • Loading branch information
h1alexbel committed Dec 27, 2024
1 parent cfac7fb commit 8dc8a6c
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 2 deletions.
15 changes: 13 additions & 2 deletions src/main/java/org/eolang/lints/Programs.java
Original file line number Diff line number Diff line change
Expand Up @@ -118,10 +118,21 @@ public Programs(final Map<String, XML> map) {
* Find defects possible defects in the XMIR file.
* @return All defects found
*/
public Collection<Defect> defects() throws IOException {
public Collection<Defect> defects() {
final Collection<Defect> messages = new LinkedList<>();
for (final Lint<Map<String, XML>> lint : this.lints) {
messages.addAll(lint.defects(this.pkg));
try {
messages.addAll(lint.defects(this.pkg));
} catch (final IOException exception) {
throw new IllegalStateException(
String.format(
"Failed to find defects in the '%s' package with '%s' lint",
this.pkg,
lint
),
exception
);
}
}
return messages;
}
Expand Down
10 changes: 10 additions & 0 deletions src/test/java/org/eolang/lints/ProgramsTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,12 @@
import java.nio.file.Files;
import java.nio.file.Path;
import org.cactoos.io.InputOf;
import org.cactoos.list.ListOf;
import org.cactoos.set.SetOf;
import org.eolang.parser.EoSyntax;
import org.hamcrest.MatcherAssert;
import org.hamcrest.Matchers;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.RepeatedTest;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
Expand Down Expand Up @@ -84,4 +86,12 @@ void checksInParallel(@Mktmp final Path dir) throws IOException {
);
}

@Test
void doesNotThrowIoException() {
Assertions.assertDoesNotThrow(
() -> new Programs(new ListOf<>()).defects(),
"Exception was thrown, but it should not be"
);
}

}

0 comments on commit 8dc8a6c

Please sign in to comment.