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

pmd / pmd / 4515

27 Mar 2025 12:01PM UTC coverage: 77.853% (+0.06%) from 77.796%
4515

push

github

adangel
Fix #5590: [java] LiteralsFirstInComparisons with constant field (#5595)

Merge pull request #5595 from oowekyala:issue5590-literal-comparison

17580 of 23536 branches covered (74.69%)

Branch coverage included in aggregate %.

106 of 110 new or added lines in 11 files covered. (96.36%)

62 existing lines in 5 files now uncovered.

38483 of 48475 relevant lines covered (79.39%)

0.8 hits per line

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

92.86
/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/ast/AbstractJavaExpr.java
1
/*
2
 * BSD-style license; for more info see http://pmd.sourceforge.net/license.html
3
 */
4

5
package net.sourceforge.pmd.lang.java.ast;
6

7
import java.util.Objects;
8

9
import org.checkerframework.checker.nullness.qual.NonNull;
10
import org.checkerframework.checker.nullness.qual.Nullable;
11

12
abstract class AbstractJavaExpr extends AbstractJavaTypeNode implements ASTExpression {
13

14
    private int parenDepth;
15
    private @Nullable ConstResult constValue;
16

17
    AbstractJavaExpr(int i) {
18
        super(i);
1✔
19
    }
1✔
20

21

22
    void bumpParenDepth() {
23
        parenDepth++;
1✔
24
    }
1✔
25

26
    @Override
27
    public int getParenthesisDepth() {
28
        return parenDepth;
1✔
29
    }
30

31
    @Override
32
    public @NonNull ConstResult getConstFoldingResult() {
33
        if (constValue == null) {
1✔
34
            constValue = ConstResult.NO_CONST_VALUE; // make non-null, so that we don't reenter on cycle
1✔
35
            constValue = doBuildConstValue();
1✔
36
            Objects.requireNonNull(constValue, "constValue must not be null");
1✔
37
        }
38
        return constValue;
1✔
39
    }
40

41
    final @NonNull ConstResult doBuildConstValue() {
42
        return acceptVisitor(ConstantFolder.INSTANCE, null);
1✔
43
    }
44

45
    /**
46
     * @deprecated Since 7.12.0. Kept for binary compatibility. This method should have been package-private from the start.
47
     *     Use {@link ASTExpression#getConstValue()} or {@link ASTExpression#getConstFoldingResult()} instead.
48
     */
49
    @Deprecated
50
    protected @Nullable Object buildConstValue() {
NEW
51
        return doBuildConstValue().getValue();
×
52
    }
53
}
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