1.2.1291. Unthrown Exception¶
These exceptions are defined in the code but never thrown. They are probably dead code.
Unused exceptions are code bloat, as they increase the size of the code without any purpose. They are also misleading, as other developers might come to the impression that there is a mechanism to handle the situation that the exception describe, yet they are generating a fatal error.
<?php
//This exception is defined but never used in the code.
class myUnusedException extends \Exception {}
//This exception is defined and used in the code.
class myUsedException extends \Exception {}
throw new myUsedException('I was called');
?>
1.2.1291.1. Connex PHP features¶
1.2.1291.1.1. Suggestions¶
Remove the exception
Find a place in the code to throw the exception
Replace an existing Exception with this more specific one
1.2.1291.1.2. Specs¶
Short name |
Exceptions/Unthrown |
Rulesets |
|
Exakat since |
0.8.4 |
PHP Version |
All |
Severity |
Minor |
Time To Fix |
Quick (30 mins) |
Precision |
Very high |
ClearPHP |
|
Available in |