I've got a rather simple IntelliJ/tool question here:
I'm currently dealing with some legacy code and started to rework stuff here and there. What I stumbled upon very often are declared (checked) exceptions in the method signature, although these exceptions are never thrown within the body.
These declarations are also not enforced by an interface or something alike, because this problem occurs mainly in MVC controllers, that apparently were always copied and pasted over and over again.
I would like to know if there's a way to search for such declared exceptions with IntelliJ.
Because if I put my caret at the throws
keyword it does not highlight anything, because the declared exception is never thrown, but the editor does not show me an error marking either, what I would really appreciate : )
Is there an option in IntelliJ to enable this feature or does a plugin exist that would do that job?
Thanks in advance.
Open settings, select Editor
-Inspections
. Find the Java
- Declaration reduncancy
- Redundant throws clause
and tick it.
Then run code analysis, though Analyze
- Inspect code
on the top level menu.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With