// ❌ Before: Keeping old code for reference// Old validation logic:// if (strlen($email) < 5) {// throw new ValidationException('Email too short');// }// if (!str_contains($email, '@')) {// throw new ValidationException('Invalid email');// }// Current validation$request->validate(['email' => 'required|email']);// ✅ After: Remove and use git log if needed$request->validate(['email' => 'required|email']);// If you need to see old code:// git log -p app/Http/Controllers/UserController.php
// ❌ Before: Commented code with explanation// This was the old way to calculate discounts:// $discount = 0;// if ($order->total > 100) {// $discount = $order->total * 0.1;// }// if ($order->user->isPremium()) {// $discount += $order->total * 0.05;// }// Current implementation$discount = $this->discountCalculator->calculate($order);// ✅ After: Move to documentation// See docs/discount-calculation.md for historical context$discount = $this->discountCalculator->calculate($order);
Commented Code Analyzer
commented-codeWhat This Checks
Why It Matters
How to Fix
Quick Fix (2 minutes)
Remove commented code and rely on version control:
2
3
4
5
6
7
8
9
10
11
12
13
14
15
Proper Fix (5 minutes)
1: Remove Old Implementation
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
2: Use Git for History
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
3: Extract to Documentation
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
4: Remove Debug Code
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
5: Remove Alternative Implementations
2
3
4
5
6
7
8
9
10
11
12
6: Remove Conditional Code Blocks
2
3
4
5
6
7
8
9
10
11
7: Customize ShieldCI Settings (Optional)
To customize the commented code detection sensitivity, publish the config:
Then in
config/shieldci.php:2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
Configuration Guide
min_consecutive_lines: Controls the minimum number of lines required to flag a block
max_neutral_lines: Controls spacing tolerance within comment blocks
code_score_threshold: Controls what counts as "code" vs documentation
$variablementions (recommended)function,class,ifstatementsReferences
Related Analyzers