Skip to content

Commit

Permalink
feat(#939): try to use Program class to verify
Browse files Browse the repository at this point in the history
  • Loading branch information
volodya-lombrozo committed Dec 9, 2024
1 parent b82384c commit 86f03be
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 1 deletion.
5 changes: 5 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,11 @@ SOFTWARE.
<artifactId>jcabi-manifests</artifactId>
<!-- version from parent POM -->
</dependency>
<dependency>
<groupId>org.eolang</groupId>
<artifactId>lints</artifactId>
<version>0.0.21</version>
</dependency>
<dependency>
<groupId>org.cactoos</groupId>
<artifactId>cactoos</artifactId>
Expand Down
23 changes: 22 additions & 1 deletion src/main/java/org/eolang/jeo/representation/VerifiedEo.java
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,10 @@
import com.jcabi.xml.StrictXML;
import com.jcabi.xml.XML;
import com.jcabi.xml.XMLDocument;
import java.io.IOException;
import java.util.Collection;
import org.eolang.lints.Defect;
import org.eolang.lints.Program;
import org.xembly.Directive;
import org.xembly.ImpossibleModificationException;
import org.xembly.Xembler;
Expand Down Expand Up @@ -58,7 +62,24 @@ final class VerifiedEo {
*/
XML asXml() throws ImpossibleModificationException {
final XML res = new XMLDocument(new Xembler(this.directives).xml());
new StrictXML(res).validate();
try {
final Collection<Defect> defects = new Program(
new StrictXML(res)
).defects();
if (defects.size() > 0) {
throw new IllegalStateException(
String.format(
"EO is incorrect: %s",
defects
)
);
}
} catch (final IOException exception) {
throw new IllegalStateException(
"Failed to verify EO",
exception
);
}
return res;
}
}

0 comments on commit 86f03be

Please sign in to comment.