Skip to content

Commit

Permalink
feat(objectionary#117): names
Browse files Browse the repository at this point in the history
  • Loading branch information
h1alexbel committed Jan 16, 2025
1 parent c2f315b commit f58befd
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions src/main/java/org/eolang/lints/errors/LtAtomIsNotUnique.java
Original file line number Diff line number Diff line change
Expand Up @@ -76,12 +76,12 @@ public Collection<Defect> defects(final Map<String, XML> pkg) throws IOException
)
);
index.forEach(
(next, natoms) -> {
(next, names) -> {
if (!Objects.equals(next, xmir)) {
final String pair = LtAtomIsNotUnique.pairHash(xmir, next);
if (!checked.contains(pair)) {
checked.add(pair);
natoms.stream()
names.stream()
.filter(fqns::contains)
.forEach(
aname -> {
Expand Down Expand Up @@ -111,18 +111,21 @@ public String motive() {
).asString();
}

private Defect singleDefect(final XML xmir, final String name, final int pos) {
private Defect singleDefect(final XML xmir, final String fqn, final int pos) {
return new Defect.Default(
this.name(),
Severity.ERROR,
xmir.xpath("/program/@name").stream()
.findFirst().orElse("unknown"),
Integer.parseInt(
xmir.xpath(
String.format("//o[@atom and @name='%s']/@line", name)
String.format(
"//o[@atom and @name='%s']/@line",
LtAtomIsNotUnique.oname(fqn)
)
).get(pos)
),
String.format("Atom '%s' is duplicated", name)
String.format("Atom '%s' is duplicated", fqn)
);
}

Expand Down

0 comments on commit f58befd

Please sign in to comment.