Loading...
Loading...
Detects code smells and anti-patterns — long methods, large classes, feature envy, data clumps, primitive obsession, dead code, magic numbers, deep nesting, and more. Uses configurable thresholds from .codeprobe-config.json when available. Trigger phrases: "code smells", "smell check", "anti-patterns", "clean code review".
npx skill4agent add nishilbhave/codeprobe-claude codeprobe-code-smells../codeprobe/shared-preamble.md../codeprobe/references/fullvendor/node_modules/dist/build/.next/setUp()beforeEach()codeprobe-solidcodeprobe-architecture.codeprobe-config.jsonseverity_overrides| Threshold | Config Key | Default |
|---|---|---|
| Long Method LOC limit | | 30 |
| Large Class LOC limit | | 300 |
| Deep Nesting max levels | | 3 |
| ID Prefix | Smell | Signal | How to Detect | Default Threshold | Severity |
|---|---|---|---|---|---|
| Long Method | Function/method exceeds LOC threshold | Count lines in each function/method body (excluding blank lines and single-line comments). Compare against | > 30 LOC | Minor |
| Large Class | Class exceeds LOC threshold | Count total lines in each class definition. Compare against | > 300 LOC | Major |
| Data Clumps | Same 3+ params passed together in 3+ places | Search for function/method signatures. Identify groups of 3+ parameters that appear together in 3+ different function signatures or call sites. These should be extracted into a parameter object or value object. | 3+ params, 3+ occurrences | Minor |
| Primitive Obsession | String/int used where a value object is warranted | Look for string/integer variables representing domain concepts: email addresses (validated by regex inline), money amounts (numeric + currency passed separately), phone numbers, status strings compared in multiple places, ZIP codes, UUIDs passed as plain strings through multiple layers. | Pattern recognition | Minor |
| ID Prefix | Smell | Signal | How to Detect | Default Threshold | Severity |
|---|---|---|---|---|---|
| Feature Envy | Method accesses another object's data 3x+ more than its own | Count how many times a method references | 3+ external accesses | Minor |
| Inappropriate Intimacy | Class accessing another's private/protected internals | Search for reflection-based access ( | Any occurrence | Major |
| Refused Bequest | Subclass inherits but doesn't use most of parent's methods | Examine subclasses: if the parent has N public methods and the subclass overrides fewer than 30% of them while also not calling | Unused majority of parent methods | Minor |
| ID Prefix | Smell | Signal | How to Detect | Default Threshold | Severity |
|---|---|---|---|---|---|
| Shotgun Surgery | Changing one concept requires edits in 5+ files | Search for a single concept (e.g., a field name, a status value, a business rule) that appears across many files. If the same constant, column name, or business term appears in 5+ files without being centralized behind a single source of truth, flag it. | 5+ files for one concept | Major |
| Divergent Change | One class modified for 3+ unrelated reasons | Examine large classes (> 200 LOC). Check whether the methods cluster around distinct, unrelated concerns. If a single class handles user authentication, email formatting, AND report generation, it has divergent change — any of those 3 areas changing forces this class to change. | 3+ distinct concerns | Major |
| ID Prefix | Smell | Signal | How to Detect | Default Threshold | Severity |
|---|---|---|---|---|---|
| Dead Code | Unreachable branches, unused imports, commented-out code blocks | Search for: (1) | Any occurrence | Minor |
| Speculative Generality | Abstractions/interfaces with only one implementation and no foreseeable second | Search for interfaces, abstract classes, or generic type parameters that have exactly one concrete implementation. If the abstraction does not appear in a DI container config or test mock, and the domain doesn't suggest future variants, flag it as premature abstraction. | Single implementation | Suggestion |
| Middle Man | Class that only delegates to another class with no added logic | Look for classes where every method simply calls the same method on an injected dependency and returns the result, with no added logic, validation, transformation, or error handling. The class adds an unnecessary indirection layer. | Pure delegation in all methods | Minor |
| ID Prefix | Smell | Signal | How to Detect | Default Threshold | Severity |
|---|---|---|---|---|---|
| Temporal Coupling | Methods must be called in specific order but nothing enforces it | Look for patterns where: (1) method A must be called before method B but there's no compile-time or runtime check, (2) | Implicit ordering dependency | Major |
| ID Prefix | Smell | Signal | How to Detect | Default Threshold | Severity |
|---|---|---|---|---|---|
| Magic Numbers | Hardcoded numeric/string literals without named constants in business logic | Search for numeric literals (other than 0, 1, -1) and string literals used in conditionals, calculations, or business logic. Flag values like | Any in logic paths | Minor |
| Boolean Blindness | Method with 2+ boolean params | Search for function/method signatures with 2 or more | 2+ boolean parameters | Minor |
| Deep Nesting | Indentation levels exceed threshold | Count nesting depth in each function: each | > 3 levels | Minor |
SMELL-SMELL-001SMELL-002UserService@registervalidateAndNormalizeInput()register()86400app/Services/CacheService.phpSECONDS_PER_DAY = 86400processOrder(bool $isExpress, bool $requiresSignature, bool $isFragile)OrderProcessor.phpShippingOptionsShippingOptionsPaymentGateway.phpReportGenerator.phpgenerate()fetchReportData()formatReport()generate()