Skip to content

Commit

Permalink
#11 check lineno
Browse files Browse the repository at this point in the history
  • Loading branch information
yegor256 committed Nov 19, 2024
1 parent a22f288 commit 0f48ba3
Showing 1 changed file with 15 additions and 2 deletions.
17 changes: 15 additions & 2 deletions src/main/java/org/eolang/lints/LintByXsl.java
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
import java.io.IOException;
import java.util.Collection;
import java.util.LinkedList;
import java.util.List;
import org.cactoos.Input;
import org.cactoos.io.ResourceOf;
import org.cactoos.text.IoCheckedText;
Expand Down Expand Up @@ -87,11 +88,23 @@ public Collection<Defect> defects(final XML xmir) {
final XML report = this.sheet.transform(xmir);
final Collection<Defect> defects = new LinkedList<>();
for (final XML defect : report.nodes("/defects/defect")) {
final List<String> line = defect.xpath("@line");
if (line.isEmpty()) {
throw new IllegalStateException(
String.format("No line number reported by %s", this.rule)
);
}
final List<String> severity = defect.xpath("@severity");
if (severity.isEmpty()) {
throw new IllegalStateException(
String.format("No severity reported by %s", this.rule)
);
}
defects.add(
new Defect.Default(
this.rule,
Severity.parsed(defect.xpath("@severity").get(0)),
Integer.parseInt(defect.xpath("@line").get(0)),
Severity.parsed(severity.get(0)),
Integer.parseInt(line.get(0)),
defect.xpath("text()").get(0)
)
);
Expand Down

0 comments on commit 0f48ba3

Please sign in to comment.