|
| 1 | +# Clean Code and SRP Audit |
| 2 | + |
| 3 | +## Summary |
| 4 | + |
| 5 | +- **Highest-leverage future split:** separate HTTP request mechanics from the |
| 6 | + 500-line `SchemaRegistryClient`, preserving its public synchronous API. |
| 7 | +- Producer, consumer, and main client are stateful lifecycle actors; splitting |
| 8 | + them without stronger concurrency coverage risks hidden ordering changes. |
| 9 | +- `AdminClient` spans topic/group/cluster operations but shares one Kafka admin |
| 10 | + backend and has bounded methods; another facade would add indirection. |
| 11 | +- Spring listener discovery and listener execution share one processor because |
| 12 | + lifecycle state connects them; a split is only useful after startup/shutdown |
| 13 | + behavior is more deeply characterized. |
| 14 | +- The baseline repair now compiles examples and cleanly separates 336 unit |
| 15 | + tests from 58 opt-in integration tests. |
| 16 | + |
| 17 | +## Findings |
| 18 | + |
| 19 | +| ID | Location | Category | Severity | Actors in conflict | Cost | Size | Behavior risk | |
| 20 | +|---|---|---|---|---|---|---|---| |
| 21 | +| JAVA-SRP-1 | `schema/SchemaRegistryClient.java` | SRP, HTTP client | P2 | Schema Registry endpoint policy; HTTP transport/auth/cache | Repeated request/status/decoding mechanics obscure endpoint-specific rules. | L | Medium | |
| 22 | +| JAVA-SRP-2 | `testcontainers/StreamlineContainer.java` | SRP, test product | P2 | container lifecycle; endpoint helpers; topic/test utility methods | Docker lifecycle and SDK-specific convenience operations change for different test actors. | L | Medium | |
| 23 | +| JAVA-CC-1 | `StreamlineAutoConfiguration`/listener processor | Spring lifecycle warning | P2 | auto-configuration; listener discovery | BeanPostProcessor construction eagerly creates configuration/client beans, producing Spring eligibility warnings. | M | Medium | |
| 24 | + |
| 25 | +## Ordered Refactor Sequence |
| 26 | + |
| 27 | +1. Characterize Schema Registry request paths, bodies, auth, statuses, and |
| 28 | + decoding with an in-process HTTP server. |
| 29 | +2. Extract a private request executor; keep endpoint policy in public methods. |
| 30 | +3. Add listener-processor tests for lazy client resolution, bean discovery, |
| 31 | + start, stop, and shutdown. |
| 32 | +4. Only then remove eager BeanPostProcessor dependencies. |
| 33 | +5. Keep producer/consumer state intact until race/lifecycle coverage improves. |
| 34 | + |
| 35 | +## Deferred |
| 36 | + |
| 37 | +- Schema Registry transport extraction needs broader endpoint tests. |
| 38 | +- Listener processor cleanup needs Spring lifecycle characterization. |
| 39 | +- Live integration remains blocked by registry access. |
| 40 | + |
| 41 | +## Out of Scope |
| 42 | + |
| 43 | +- `StreamlineConfig`/`StreamlineProperties`: public configuration contracts. |
| 44 | +- Producer and consumer: cohesive stateful actors. |
| 45 | +- `AdminClient`: one Kafka administration backend. |
| 46 | +- Examples: compiled documentation product, intentionally separate module. |
0 commit comments