Analyze Dead Code in the Project
已回答
It is possible to analyze whole project and see if there is a dead code? The code can be considered as dead if:
- There aren't any usage of it.
- Code (method or constant) is used only in tests.
As an example you can see at https://github.com/hanna-eismant/dead-code-example. There is method (https://github.com/hanna-eismant/dead-code-example/blob/d28128e5e17e0fd99bae90466858673069710f0f/src/main/java/org/example/MessagePrinter.java#L5) that is used only in test and that is not highlighted anyhow.
请先登录再写评论。
Hello Hanna! That should have been solved by option in inspection "Java | Declaration redundancy | Unused declaration": "Entry points | When entry points are in test sources, mark callees as" set to `unused`, but we still have the ticket for this, please vote and follow https://youtrack.jetbrains.com/issue/IDEA-183482.
Updated the ticket state, thank you for the report.
@..., thanks for your answer, I will be waiting when this bug is fixed.
Additionally, it would be great to have an improvement to show this inspection not only for open file and analyse all production files in project.
You can always run "Code | Inspect Code" or run a single inspection manually against the module/project/defined scope. It is also possible to run inspections with Qodana and even from the command line.