Affects PMD Version: 7.x
Rule: UnusedPrivateMethod
Please provide the rule name and a link to the rule documentation:
https://docs.pmd-code.org/pmd-doc-7.2.0/pmd_rules_java_bestpractices.html#unusedprivatemethod
Description:
When using static private methods as lambda in enum, it treats the methods as unused while it is still being used in enum declaration
Code Sample demonstrating the issue:
@Getter
@RequiredArgsConstructor
enum GenerationType {
APPLE_DESKTOP("https://apps.apple.com/app/id", GenerationType::isAppleType),
APPLE_ITUNES("https://itunes.apple.com/app/id", GenerationType::isAppleType),
SAMSUNG("https://www.samsung.com/us/appstore/app/", GenerationType::isSamsungType),
ROKU("https://channelstore.roku.com/details/", GenerationType::isRokuType),
AMAZON("https://www.amazon.com/dp/", GenerationType::isAmazonType),
ANDROID("https://play.google.com/store/apps/details?id=", GenerationType::isAndroidType);
private final String baseUrl;
private final Predicate<String> predicate;
private static boolean isAppleType(String data) {
return "apple".equals(data);
}
private static boolean isRokuType(String data) {
return "roku".equals(data);
}
private static boolean isSamsungType(String data) {
return "samsung".equals(data);
}
private static boolean isAmazonType(String data) {
return "amazon".equals(data);
}
private static boolean isAndroidType(String data) {
return "android".equals(data);
}
}
Expected outcome:
The above methods should not be reported as being usunsed.
Running PMD through: Maven
Affects PMD Version: 7.x
Rule: UnusedPrivateMethod
Please provide the rule name and a link to the rule documentation:
https://docs.pmd-code.org/pmd-doc-7.2.0/pmd_rules_java_bestpractices.html#unusedprivatemethod
Description:
When using static private methods as lambda in enum, it treats the methods as unused while it is still being used in enum declaration
Code Sample demonstrating the issue:
Expected outcome:
The above methods should not be reported as being usunsed.
Running PMD through: Maven