We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
Affects PMD Version: 6.44.0+ 7.0.0
Rule: AtLeastOneConstructor
Please provide the rule name and a link to the rule documentation: https://pmd.github.io/latest/pmd_rules_java_codestyle.html#atleastoneconstructor
Description:
Code Sample demonstrating the issue:
public class ToString implements java.util.Function<Object, String> { @Override public String apply(Object arg) { return arg.toString(); } }
@org.junit.Test
public class AbstractForSomeReason { // violation at this line @org.junit.Test / @Before / @After / @BeforeSuite / @BeforeGroup / @etc. public void test() { // implementation } }
public class ClassTest { // violation at this line, but here is workaround below public void test() { // implementation } }
could be fixed by the following configuration
<rule ref="category/java/codestyle.xml/AtLeastOneConstructor"> <properties> <property name="violationSuppressXPath" value=".[ends-with(@SimpleName,'Test')]"/> <property name="ignoredAnnotations" value="lombok.Data|lombok.Value|lombok.Builder|lombok.NoArgsConstructor|lombok.RequiredArgsConstructor|lombok.AllArgsConstructor|org.springframework.context.annotation.Configuration|org.springframework.web.bind.annotation.ControllerAdvice|org.springframework.web.bind.annotation.RestController|lombok.experimental.SuperBuilder|org.springframework.stereotype.Component|org.springframework.stereotype.Service|org.springframework.stereotype.Repository|org.springframework.boot.context.properties.ConfigurationProperties|org.mapstruct.Mapper|javax.xml.bind.annotation.XmlRootElement|org.junit.jupiter.api.extension.ExtendWith|org.mockserver.junit.jupiter.MockServerSettings|org.springframework.test.context.ContextConfiguration|org.springframework.test.context.web.WebAppConfiguration|org.junit.runner.RunWith" /> </properties> </rule>
Expected outcome:
PMD reports a violation in case1 and case2, but that's wrong. That's a false positive. The possible ways of resolution:
ignoredAnnotations
<property name="ignoredAnnotations" value="lombok.Data|org.junit.Test" />
@lombok.Data
<property name="allowedInterfaces" value="java.lang|org.apache.camel.Processor"/>
Running PMD through: Gradle
The text was updated successfully, but these errors were encountered:
Rule AtLeastOneConstructor does not make sense for @UtilityClass annotations. Interferres with IDE rule: No constructors for UtilityClasses.
Sorry, something went wrong.
No branches or pull requests
Affects PMD Version:
6.44.0+
7.0.0
Rule: AtLeastOneConstructor
Please provide the rule name and a link to the rule documentation:
https://pmd.github.io/latest/pmd_rules_java_codestyle.html#atleastoneconstructor
Description:
Code Sample demonstrating the issue:
@org.junit.Test
, etc.could be fixed by the following configuration
Expected outcome:
PMD reports a violation in case1 and case2, but that's wrong. That's a false positive.
The possible ways of resolution:
ignoredAnnotations
to support method-level (not only class-level as implemented now)@lombok.Data
is class-level annotation, and@org.junit.Test
is method-level annotationRunning PMD through: Gradle
The text was updated successfully, but these errors were encountered: