You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Description:
Hi, I found a false negative about the rule UnusedPrivateField, please read the following code example. In line 3, the code has an annotation @SpyBean, which means that the filed service could be used in testing. However, PMD reports a warning of this rule.
Besides, in src file, PMD has considered @MockBen, and it doesn't report identical warning for the field with MockBean. Hence, I think this is a false positive.
Code Sample demonstrating the issue:
importorg.springframework.boot.test.mock.mockito.SpyBean;
publicclassC {
@SpyBeanprivateServiceservice; // a false warning of this field
}
Expected outcome:
PMD reports a violation at line 4, but that's wrong. That's a false positive.
Running PMD through:[Maven]
The text was updated successfully, but these errors were encountered:
adangel
changed the title
A false positive about the rule UnusedPrivateField
[java] UnusedPrivateField - false positive with Mockito @SpyBean
Jul 7, 2022
adangel
changed the title
[java] UnusedPrivateField - false positive with Mockito @SpyBean
[java] UnusedPrivateField - false positive with Spring @SpyBean
Jul 7, 2022
Affects PMD Version:6.47.0
Rule:UnusedPrivateField
Please provide the rule name and a link to the rule documentation:
https://pmd.github.io/latest/pmd_rules_java_bestpractices.html#unusedprivatefield
Description:
Hi, I found a false negative about the rule UnusedPrivateField, please read the following code example. In line 3, the code has an annotation
@SpyBean
, which means that the filedservice
could be used in testing. However, PMD reports a warning of this rule.Besides, in src file, PMD has considered
@MockBen
, and it doesn't report identical warning for the field withMockBean
. Hence, I think this is a false positive.Code Sample demonstrating the issue:
Expected outcome:
PMD reports a violation at line 4, but that's wrong. That's a false positive.
Running PMD through: [Maven]
The text was updated successfully, but these errors were encountered: