Join GitHub today
GitHub is home to over 28 million developers working together to host and review code, manage projects, and build software together.Sign up
UnusedImports behaviour is different from documentation #3741
/var/tmp $ javac Test.java
/var/tmp $ cat Test.java
/var/tmp $ cat config.xml
/var/tmp $ java -jar checkstyle-7.4-all.jar -c config.xml Test.java
Describe what you expect in detail.
As documented in the third item of UnusedImports description,
I expect the import of
I'm aware there is a RedundantImport which can perform this check correctly, and in documentation it is just a proper subset of UnusedImport, so maybe this issue is just because of outdated documentation.
The problem is due to the fact that we treat identifiers from java.lang package as references and add them into references list in processIdent method. I think all imports from java.lang should be treated as unused. In order to do this we can filter them in finishTree for example or earlier.