Skip to content

[java] MissingStaticMethodInNonInstantiatableClass: False positive with Lombok Builder on Constructor #1488

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
mrclmh opened this issue Nov 29, 2018 · 1 comment · Fixed by #5109
Labels
a:false-positive PMD flags a piece of code that is not problematic
Milestone

Comments

@mrclmh
Copy link

mrclmh commented Nov 29, 2018

Affects PMD Version:
6.9.0+
7.0.0

Rule: MissingStaticMethodInNonInstantiatableClass

Description:
Using Lomboks Builder annotation on a private constructor triggers MissingStaticMethodInNonInstantiatableClass altough the static builder() method is generated and can be used normally.

Code Sample demonstrating the issue:

package org.example.foo;

import lombok.Builder;

/**
 * TestClass.
 */
public class TestClass {
    @Builder
    private TestClass(final String foo, final Integer bar) {
    }
}

Running PMD through: [Gradle 3.5]

@adangel adangel added the a:false-positive PMD flags a piece of code that is not problematic label Nov 29, 2018
@jsotuyod jsotuyod added the needs:pmd7-revalidation The issue hasn't yet been retested vs PMD 7 and may be stale label Mar 17, 2024
@jsotuyod jsotuyod removed the needs:pmd7-revalidation The issue hasn't yet been retested vs PMD 7 and may be stale label Mar 31, 2024
@kdebski85
Copy link
Contributor

I added a PR #5109 to fix the issue.

As a workaround, you can add lombok.Builder to annotations:

    <rule ref="category/java/errorprone.xml/MissingStaticMethodInNonInstantiatableClass">
        <properties>
            <property name="annotations" value="org.springframework.beans.factory.annotation.Autowired,javax.inject.Inject,com.google.inject.Inject,lombok.Builder" />
        </properties>
    </rule>

@adangel adangel changed the title [java] False positive of MissingStaticMethodInNonInstantiatableClass with Lombok Builder on Constructor [java] MissingStaticMethodInNonInstantiatableClass: False positive with Lombok Builder on Constructor Jul 19, 2024
@adangel adangel added this to the 7.4.0 milestone Jul 19, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
a:false-positive PMD flags a piece of code that is not problematic
Projects
None yet
4 participants