Skip to content

Commit

Permalink
feat(objectionary#114): streams
Browse files Browse the repository at this point in the history
  • Loading branch information
h1alexbel committed Jan 3, 2025
1 parent c9513dd commit 2b88016
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions src/main/java/org/eolang/lints/errors/LtObjectIsNotUnique.java
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,6 @@ public Collection<Defect> defects(final Map<String, XML> pkg) {
if (xmir.nodes("/program/objects/o").isEmpty()) {
continue;
}
final Map<String, String> original = LtObjectIsNotUnique.programObjects(xmir);
for (final XML oth : pkg.values()) {
if (Objects.equals(oth, xmir)) {
continue;
Expand All @@ -69,12 +68,7 @@ public Collection<Defect> defects(final Map<String, XML> pkg) {
final Map<String, String> other = LtObjectIsNotUnique.programObjects(oth);
for (final Map.Entry<String, String> object : other.entrySet()) {
final String name = object.getKey();
if (
!(original.containsKey(name)
&& LtObjectIsNotUnique.packageName(oth)
.equals(LtObjectIsNotUnique.packageName(xmir))
)
) {
if (!LtObjectIsNotUnique.containDuplicate(xmir, oth, name)) {
continue;
}
defects.add(
Expand Down Expand Up @@ -108,6 +102,12 @@ public String motive() throws Exception {
).asString();
}

private static boolean containDuplicate(final XML original, final XML oth, final String name) {
return LtObjectIsNotUnique.programObjects(original).containsKey(name)
&& LtObjectIsNotUnique.packageName(oth)
.equals(LtObjectIsNotUnique.packageName(original));
}

private static Map<String, String> programObjects(final XML xmir) {
final List<String> names = xmir.xpath("/program/objects/o/@name");
return IntStream.range(0, names.size())
Expand Down

0 comments on commit 2b88016

Please sign in to comment.