• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

CyclopsMC / CyclopsCore / #479033821

15 Feb 2026 06:24AM UTC coverage: 22.618% (+0.5%) from 22.089%
#479033821

Pull #217

github

web-flow
Merge 67551548d into 21ed06935
Pull Request #217: Fix logical operator evaluation context and test syntax

77 of 92 new or added lines in 6 files covered. (83.7%)

30 existing lines in 1 file now uncovered.

2374 of 10496 relevant lines covered (22.62%)

0.23 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

65.22
/src/main/java/org/cyclops/cyclopscore/nbt/path/parse/NbtPathExpressionHelpers.java
1
package org.cyclops.cyclopscore.nbt.path.parse;
2

3
import net.minecraft.nbt.ByteTag;
4
import net.minecraft.nbt.Tag;
5

6
/**
7
 * Utility methods for NBT path expression handling.
8
 */
NEW
9
public class NbtPathExpressionHelpers {
×
10

11
    /**
12
     * Determine if a tag is truthy.
13
     * ByteTag with value 1 is true, 0 is false.
14
     * Any other non-null tag is considered true.
15
     * This follows the same logic as {@link org.cyclops.cyclopscore.nbt.path.INbtPathExpression#test(Tag)}.
16
     *
17
     * @param tag The tag to check
18
     * @return true if the tag is truthy, false otherwise
19
     */
20
    public static boolean isTruthy(Tag tag) {
21
        if (tag == null) {
1✔
NEW
22
            return false;
×
23
        }
24
        if (tag.getId() == Tag.TAG_BYTE) {
1✔
25
            return ((ByteTag) tag).getAsByte() == (byte) 1;
1✔
26
        }
27
        // Non-null non-ByteTags are truthy
NEW
28
        return true;
×
29
    }
30

31
    /**
32
     * Find the end position of an expression, stopping at logical operators or closing parenthesis.
33
     * This method is shared by logical operator handlers to identify expression boundaries.
34
     *
35
     * @param expression The full expression string
36
     * @param start The starting position to search from
37
     * @return The position where the expression ends
38
     */
39
    public static int findExpressionEnd(String expression, int start) {
40
        int depth = 0;
1✔
41
        for (int i = start; i < expression.length(); i++) {
1✔
42
            char c = expression.charAt(i);
1✔
43

44
            if (c == '(') {
1✔
NEW
45
                depth++;
×
46
            } else if (c == ')') {
1✔
NEW
47
                if (depth == 0) {
×
NEW
48
                    return i;
×
49
                }
NEW
50
                depth--;
×
51
            } else if (depth == 0) {
1✔
52
                // Check for logical operators at top level
53
                if (i + 1 < expression.length()) {
1✔
54
                    String twoChar = expression.substring(i, i + 2);
1✔
55
                    if (twoChar.equals("&&") || twoChar.equals("||")) {
1✔
56
                        return i;
1✔
57
                    }
58
                }
59
                // Check for NOT operator (but not != which is handled differently)
60
                if (c == '!' && (i + 1 >= expression.length() || expression.charAt(i + 1) != '=')) {
1✔
NEW
61
                    return i;
×
62
                }
63
            }
64
        }
65
        return expression.length();
1✔
66
    }
67
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc