Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

IntelliJ: Search for Checked exceptions, declared in method signature, but never thrown in body [closed]

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.

like image 609
Unknown Id Avatar asked Dec 11 '22 18:12

Unknown Id


1 Answers

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.

enter image description here

like image 63
Tobb Avatar answered Jan 23 '23 00:01

Tobb