Commit 965a77e
authored
* feat(deslop): add code smell detection patterns (#106)
Add high-impact code smell detection patterns:
High-Certainty Patterns (regex-based):
- boolean_blindness: Functions with 3+ consecutive boolean params
- message_chains_methods: Long method chains (4+ calls)
- message_chains_properties: Deep property access (5+ levels)
- mutable_globals_js: Mutable globals with UPPERCASE names
- mutable_globals_py: Mutable global collections in Python
Heuristic Patterns (may have false positives):
- feature_envy: Method using another object 3+ times
- speculative_generality_unused_params: Underscore-prefixed params
- speculative_generality_empty_interface: Empty TypeScript interfaces
Multi-Pass Analyzers:
- analyzeDeadCode: Unreachable code after return/throw/break/continue
- analyzeShotgunSurgery: Files frequently changing together (git analysis)
Pattern skeleton added for dead_code and shotgun_surgery (requiresMultiPass).
* test(deslop): add comprehensive tests for code smell detection (#106)
Add tests for new code smell detection patterns:
High-Certainty Pattern Tests:
- boolean_blindness: 3+ consecutive boolean params
- message_chains_methods: 4+ method call chains
- message_chains_properties: 5+ property access chains
- mutable_globals_js: let/var UPPERCASE in JS
- mutable_globals_py: mutable collections in Python
Heuristic Pattern Tests:
- feature_envy: repeated access to another object
- speculative_generality_unused_params: underscore-prefixed params
- speculative_generality_empty_interface: empty TS interfaces
Multi-Pass Analyzer Tests:
- analyzeDeadCode: unreachable code detection (JS, Python, Go, Rust)
- analyzeShotgunSurgery: git co-change analysis
Also:
- Fixed analyzeDeadCode to handle "} else {" patterns
- Added ReDoS safety tests for all new patterns
- Added language filtering tests
* docs(deslop): update documentation and sync library for code smell detection (#106)
- Add code smell detection section to deslop-around.md
- Add CHANGELOG entry for all new patterns and analyzers
- Sync slop-patterns.js and slop-analyzers.js to all plugins
* docs(readme): add code smell detection to deslop-around features
Updated the README.md `/deslop-around` section to include the newly
added code smell detection patterns:
- Boolean blindness
- Message chains
- Mutable globals
- Dead code
- Shotgun surgery
This ensures the main README is consistent with the detailed
documentation in CHANGELOG.md and deslop-around.md.
* fix(deslop): improve analyzeDeadCode for Python and one-line conditionals
Addresses review feedback from Gemini and Codex:
1. **Python indentation tracking** - Use indentation-based scope detection
instead of brace-counting for Python files. Fixes false positives where
next function definition was flagged as dead code.
2. **One-line conditional detection** - Skip termination statements that are
part of one-line conditionals (e.g., "if (x) return;"). These don't make
subsequent code unreachable.
3. **Language-aware block detection** - Maintains brace-depth tracking for
JS/Go/Rust while using indentation for Python.
Fixes issues reported in PR #115 review.
* fix(deslop): correct Python indentation logic in analyzeDeadCode
Fix indentation level check to allow same-level code (dead code) while
stopping only when dedented to a lesser indentation (exited block).
Previous logic stopped at same-or-less indentation, which prevented
detecting dead code at the same level as the return statement.
Now correctly detects:
def test():
return 42
print('unreachable') # Same indentation = dead code
* chore: trigger CI rerun
* fix(deslop): prevent ReDoS in message_chains patterns
Add bounds to regex quantifiers to prevent catastrophic backtracking:
- Word boundary \b at start (prevents matching mid-string)
- Identifier length limit: 100 chars max
- Method argument limit: 200 chars max
- Repetition bounds: 4-8 for methods, 5-10 for properties
Fixes CI test failure: 'message_chains patterns should resist ReDoS'
* chore: remove accidental test output files
* fix(analyzers): address review feedback - command injection validation
- Add commitLimit validation in analyzeShotgunSurgery to prevent command injection
- Sync validated changes to all plugin lib copies
1 parent 4e3c339 commit 965a77e
43 files changed
Lines changed: 11340 additions & 82 deletions
File tree
- __tests__
- lib/patterns
- plugins
- deslop-around
- commands
- lib
- patterns
- reality-check
- next-task/lib
- patterns
- reality-check
- project-review/lib
- patterns
- reality-check
- reality-check/lib
- patterns
- platform
- schemas
- sources
- state
- types
- utils
- ship/lib
- patterns
- reality-check
Some content is hidden
Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
81 | 81 | | |
82 | 82 | | |
83 | 83 | | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
84 | 100 | | |
85 | 101 | | |
86 | 102 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
169 | 169 | | |
170 | 170 | | |
171 | 171 | | |
| 172 | + | |
172 | 173 | | |
173 | 174 | | |
174 | 175 | | |
| |||
0 commit comments