I have been getting the following PMD warning that I can’t seem to suppress with PMD’s @SuppressWarnings
RequestServiceImpl.java:1, UnnecessaryFullyQualifiedName, Priority: Normal Unnecessary use of fully qualified name 'com.choonchernlim.epicapp.service.impl' due to existing import 'com.choonchernlim.epicapp.service.*'.
The reason I’m getting this warning is because IntelliJ will automatically replace all single imports from the same package with a wildcard ‘*’ when the class count hits a certain limit.
By using wildcard imports, it also becomes difficult for my peers to understand where the classes are coming from.
To fix this permanently in IntelliJ:-
- Go to Preferences… › Code Style › Java.
- Go to Imports tab.
- Check Use single class import
- Set a ridiculous high number on Class count to use import with ‘*’ and Names count to use static import with ‘*’ because these fields cannot be empty. In my case, I set 100 for each field.
- Select OK.
Finally, perform an Optimize Imports… on that Java file in question.