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

pmd / pmd / 964

12 Nov 2026 12:04PM UTC coverage: 80.243% (-0.005%) from 80.248%
964

push

github

web-flow
[java] Fix #6731: Support lombok.Builder (fix UnnecessaryFullyQualifiedName false positive) (#7198)

UnnecessaryFullyQualifiedName reported lombok.Builder when the generated
builder class was named Builder. Add that static nested class to the
enclosing type's symbol, as with other Lombok members, instead of
special-casing the rule. The default name is <TypeName>Builder; builderClassName
overrides it, and an existing nested class of that name is kept.

Fixes #6731

20766 of 26864 branches covered (77.3%)

Branch coverage included in aggregate %.

67 of 83 new or added lines in 5 files covered. (80.72%)

44277 of 54194 relevant lines covered (81.7%)

0.82 hits per line

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

78.26
/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/symbols/internal/ast/SymbolResolutionPass.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.symbols.internal.ast;
6

7
import java.util.Collections;
8
import java.util.List;
9
import java.util.Objects;
10

11
import org.checkerframework.checker.nullness.qual.Nullable;
12
import org.pcollections.PSet;
13

14
import net.sourceforge.pmd.lang.ast.NodeStream;
15
import net.sourceforge.pmd.lang.java.ast.ASTAnnotation;
16
import net.sourceforge.pmd.lang.java.ast.ASTCompilationUnit;
17
import net.sourceforge.pmd.lang.java.ast.ASTTypeDeclaration;
18
import net.sourceforge.pmd.lang.java.ast.InternalApiBridge;
19
import net.sourceforge.pmd.lang.java.ast.SymbolDeclaratorNode;
20
import net.sourceforge.pmd.lang.java.internal.JavaAstProcessor;
21
import net.sourceforge.pmd.lang.java.symbols.JClassSymbol;
22
import net.sourceforge.pmd.lang.java.symbols.JTypeDeclSymbol;
23
import net.sourceforge.pmd.lang.java.symbols.SymbolResolver;
24
import net.sourceforge.pmd.lang.java.symbols.SymbolicValue.SymAnnot;
25
import net.sourceforge.pmd.util.CollectionUtil;
26

27

28
/**
29
 * Populates symbols on declaration nodes.
30
 */
31
public final class SymbolResolutionPass {
1 ✔
32

33
    private SymbolResolutionPass() {
34
        // façade
35
    }
36

37
    /**
38
     * Traverse the given compilation unit, creating symbols on all
39
     * {@link SymbolDeclaratorNode}s.
40
     *
41
     * @param processor Processor
42
     * @param root      Root node
43
     *
44
     * @return A symbol resolver for all encountered type declarations.
45
     *     This is used to avoid hitting the classloader for local declarations.
46
     */
47
    public static SymbolResolver traverse(JavaAstProcessor processor, ASTCompilationUnit root) {
48
        AstSymbolMakerVisitor visitor = new AstSymbolMakerVisitor(root);
1 ✔
49
        root.acceptVisitor(visitor, new AstSymFactory(processor));
1 ✔
50
        return visitor.makeKnownSymbolResolver();
1 ✔
51
    }
52

53
    /**
54
     * @return builder classes added to this type, if any
55
     */
56
    public static List<JClassSymbol> desugarLombokMembers(JavaAstProcessor processor, ASTTypeDeclaration type) {
57
        assert processor.hasFirstClassLombokSupport() : "This method should not be called if Lombok support is disabled";
1 !
58

59
        JClassSymbol symbol = type.getSymbol();
1 ✔
60
        if (symbol instanceof AstClassSym) {
1 !
61
            return ((AstClassSym) symbol).processLombok(processor);
1 ✔
62
        }
NEW
63
        return Collections.emptyList();
×
64
    }
65

66
    /**
67
     * Converts between nodes to {@link SymAnnot}. Annotations that could not be converted,
68
     * eg because they are written with invalid code, are discarded.
69
     */
70
    public static PSet<SymAnnot> buildSymbolicAnnotations(NodeStream<ASTAnnotation> annotations) {
71
        return annotations.toStream()
1 ✔
72
                          .map(SymbolResolutionPass::toValidAnnotation)
1 ✔
73
                          .filter(Objects::nonNull)
1 ✔
74
                          .collect(CollectionUtil.toPersistentSet());
1 ✔
75
    }
76

77
    private static @Nullable SymAnnot toValidAnnotation(ASTAnnotation node) {
78
        JTypeDeclSymbol sym = InternalApiBridge.getReferencedSym(node.getTypeNode());
1 ✔
79
        if (sym instanceof JClassSymbol) {
1 !
80
            return new AstSymbolicAnnot(node, (JClassSymbol) sym);
1 ✔
81
        }
82
        return null;
×
83
    }
84
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE TRIAL · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc