# Dead Code Analyzer
Category | Severity | Time To Fix |
---|---|---|
✅ Reliability | Minor | 10 minutes |
Class: Enlightn\Enlightn\Analyzers\Reliability\DeadCodeAnalyzer
# Introduction
This analyzer scans your application source for any unreachable or dead code.
This analyzer is quite the wizard and detects the following situations:
- Unreachable statements (e.g. code after return statements).
- Unused methods or constants.
- Statements that do not do anything (no-op).
As an example of a no-op, consider the following code:
function exampleFn(array $a) {
if (count($a) === 0) {
foreach ($a as $val) {
echo $a;
}
}
}
In the example code above, the highlighted line is a no-op because it is iterating over an empty array every time.
Viewing Detailed Error Messages
To view detailed error messages, use the --details
option while running the enlightn
Artisan command.
# How To Fix
To fix this issue, you can delete all unreachable or dead code to improve code readability.